OpenSSHで長いホスト名のサーバー接続失敗(too long for Unix domain socket)


unix_listener: path "/home/matoken/.ssh/tmp/ssh-${USER}@${長いホスト名}:22.r3NYV60KUEAXUuRZ" too long for Unix domain socket

hostnameが長くて, ControlPath で設定したファイルの作成時にファイルシステムの制限で失敗しているようです.

とりあえず ssh のオプションで -o ControlMaster=no をつけて実行すると繋がります.

~/.ssh/config の対象hostで ControlMaster no としてみたけど効かないようで同じエラーになりました.

  ControlMaster no
  ControlPath no

man 5 ssh_config を見ると ControlPath に使える変数で %C を指定することで %l%h%p%r のハッシュになるようです.

             Specify the path to the control socket used for connection sharing as described in the ControlMaster section above or the string none to disable connection sharing.  Arguments to ControlPath may use the tilde
             syntax to refer to a user's home directory, the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.  It is recommended that any ControlPath used
             for opportunistic connection sharing include at least %h, %p, and %r (or alternatively %C) and be placed in a directory that is not writable by other users.  This ensures that shared connections are uniquely
     Arguments to some keywords can make use of tokens, which are expanded at runtime:

           %%    A literal ‘%’.
           %C    Hash of %l%h%p%r.
           %d    Local user's home directory.
           %f    The fingerprint of the server's host key.
           %H    The known_hosts hostname or address that is being searched for.
           %h    The remote hostname.
           %I    A string describing the reason for a KnownHostsCommand execution: either ADDRESS when looking up a host by address (only when CheckHostIP is enabled), HOSTNAME when searching by hostname, or ORDER when
                 preparing the host key algorithm preference list to use for the destination host.
           %i    The local user ID.
           %K    The base64 encoded host key.
           %k    The host key alias if specified, otherwise the original remote hostname given on the command line.
           %L    The local hostname.
           %l    The local hostname, including the domain name.
           %n    The original remote hostname, as given on the command line.
           %p    The remote port.
           %r    The remote username.
           %T    The local tun(4) or tap(4) network interface assigned if tunnel forwarding was requested, or "NONE" otherwise.
           %t    The type of the server host key, e.g.  ssh-ed25519.
           %u    The local username.

     CertificateFile, ControlPath, IdentityAgent, IdentityFile, KnownHostsCommand, LocalForward, Match exec, RemoteCommand, RemoteForward, and UserKnownHostsFile accept the tokens %%, %C, %d, %h, %i, %k, %L, %l, %n, %p,
     %r, and %u.

     KnownHostsCommand additionally accepts the tokens %f, %H, %I, %K and %t.

     Hostname accepts the tokens %% and %h.

     LocalCommand accepts all tokens.

     ProxyCommand accepts the tokens %%, %h, %n, %p, and %r.

これを ~/.ssh/config に設定してみると( ControlPath ~/.ssh/tmp/%C )こんな感じの a1e724af86ad309c968737a2fb73a3f1c0298e05 40文字のハッシュのファイル名になってとりあえず解決しました.人間には優しくないけどそう見るものではないのでいいかな?

$ dpkg-query -W openssh-client tor
openssh-client  1:8.9p1-3
$ lsb_release -dr
Description:    Debian GNU/Linux bookworm/sid
Release:        unstable
$ arch


メールアドレスが公開されることはありません。 * が付いている欄は必須項目です