I'm attempting a gateway hop through servers A -> B -> C, and would like to have this connection as an entry in my SSH config.
SSHing from A into B works. And then from B to C works. As does ssh B -t ssh C.
However, when I attempt use the following SSH config file, it fails.
Host B Hostname B Host C Hostname C ProxyJump B Host * User username ForwardAgent yes PKCS11Provider /usr/lib/ssh-keychain.dylib When running this verbosely, I find I'm running into a problem with
debug1: getpeername failed: Bad file descriptor This answer seems to suggest that problem arises from the lookup for C not being found (namely, inside the /etc/hosts file). When I look at the contents of /etc/hosts on B, all the final host locations I would like to connect to (including C) are listed. So I believe I want my connection to use B's /etc/hosts listing when making the final connection. Is there a way I can specify this in A's SSH config?
Note, I do not have root permissions on any of the machines (A, B, nor C).
Debug log:
username@A ~ % ssh C -v OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /Users/username/.ssh/config debug1: /Users/username/.ssh/config line 14: Applying options for C debug1: /Users/username/.ssh/config line 19: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: Setting implicit ProxyCommand from ProxyJump: ssh -v -W '[%h]:%p' B debug1: Executing proxy command: exec ssh -v -W '[C]:22' B OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /Users/username/.ssh/config debug1: /Users/username/.ssh/config line 19: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: Connecting to B [111.111.111.111] port 22. debug1: Connection established. debug1: provider /usr/lib/ssh-keychain.dylib: manufacturerID <Apple, Inc.> cryptokiVersion 2.20 libraryDescription <Keychain emulation PKCS#11 API> libraryVersion 0.0 debug1: provider /usr/lib/ssh-keychain.dylib slot 0: label <Key For PIV Authentication (Use> manufacturerID <Apple, Inc.> model <Keychain> serial <000000> flags 0x404 debug1: have 1 keys debug1: provider /usr/lib/ssh-keychain.dylib slot 1: label <Key For Digital Signature (User> manufacturerID <Apple, Inc.> model <Keychain> serial <000000> flags 0x404 debug1: have 2 keys debug1: identity file /Users/username/.ssh/id_rsa type -1 debug1: identity file /Users/username/.ssh/id_rsa-cert type -1 debug1: identity file /Users/username/.ssh/id_dsa type -1 debug1: identity file /Users/username/.ssh/id_dsa-cert type -1 debug1: identity file /Users/username/.ssh/id_ecdsa type -1 debug1: identity file /Users/username/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/username/.ssh/id_ed25519 type -1 debug1: identity file /Users/username/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/username/.ssh/id_xmss type -1 debug1: identity file /Users/username/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.9 debug1: provider /usr/lib/ssh-keychain.dylib: manufacturerID <Apple, Inc.> cryptokiVersion 2.20 libraryDescription <Keychain emulation PKCS#11 API> libraryVersion 0.0 debug1: provider /usr/lib/ssh-keychain.dylib slot 0: label <Key For PIV Authentication (Use> manufacturerID <Apple, Inc.> model <Keychain> serial <000000> flags 0x404 debug1: have 1 keys debug1: provider /usr/lib/ssh-keychain.dylib slot 1: label <Key For Digital Signature (User> manufacturerID <Apple, Inc.> model <Keychain> serial <000000> flags 0x404 debug1: have 2 keys debug1: identity file /Users/username/.ssh/id_rsa type -1 debug1: identity file /Users/username/.ssh/id_rsa-cert type -1 debug1: identity file /Users/username/.ssh/id_dsa type -1 debug1: identity file /Users/username/.ssh/id_dsa-cert type -1 debug1: identity file /Users/username/.ssh/id_ecdsa type -1 debug1: identity file /Users/username/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/username/.ssh/id_ed25519 type -1 debug1: identity file /Users/username/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/username/.ssh/id_xmss type -1 debug1: identity file /Users/username/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.9 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to B:22 as 'username' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:XXXXXXXXXXXXXXXXXXXXXXX debug1: Host 'B' is known and matches the ECDSA host key. debug1: Found key in /Users/username/.ssh/known_hosts:5 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 4294967296 blocks debug1: Will attempt key: /usr/lib/ssh-keychain.dylib RSA SHA256:YYYYYYYYYYYYYYYYYYYYYYYYY token agent debug1: Will attempt key: /usr/lib/ssh-keychain.dylib RSA SHA256:ZZZZZZZZZZZZZZZZZZZZZZZZZ token agent debug1: Will attempt key: /Users/username/.ssh/id_rsa debug1: Will attempt key: /Users/username/.ssh/id_dsa debug1: Will attempt key: /Users/username/.ssh/id_ecdsa debug1: Will attempt key: /Users/username/.ssh/id_ed25519 debug1: Will attempt key: /Users/username/.ssh/id_xmss debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering public key: /usr/lib/ssh-keychain.dylib RSA SHA256:YYYYYYYYYYYYYYYYYYYYYYYYY token agent debug1: Server accepts key: /usr/lib/ssh-keychain.dylib RSA SHA256:YYYYYYYYYYYYYYYYYYYYYYYYY token agent debug1: pkcs11_provider_unref: 0x111111111111 refcount 3 debug1: pkcs11_provider_unref: 0x111111111111 refcount 2 debug1: Authentication succeeded (publickey). Authenticated to B ([111.111.111.111]:22). debug1: channel_connect_stdio_fwd C:22 debug1: channel 0: new [stdio-forward] debug1: getpeername failed: Bad file descriptor debug1: Requesting [email protected] debug1: Entering interactive session. debug1: pledge: exec debug1: client_input_global_request: rtype [email protected] want_reply 0 debug1: Remote: Agent forwarding disabled. debug1: Remote: Port forwarding disabled. debug1: Remote: User rc execution disabled. debug1: Remote: Agent forwarding disabled. debug1: Remote: Port forwarding disabled. debug1: Remote: User rc execution disabled. channel 0: open failed: administratively prohibited: open failed stdio forwarding failed ssh_exchange_identification: Connection closed by remote host /etc/ssh/ssh_config
Host * SendEnv LANG LC_* ForwardX11 yes ForwardX11Trusted yes XAuthLocation /opt/X11/bin/xauth
ProxyCommandinstead ofJumpProxy. See this article for more info.ProxyCommand ssh B -W %h:%pas an alternative toJumpProxy B, but this results in the same issue. Are you recommending any specific variation of theProxyCommandparameters?ssh -v./etc/ssh/ssh_configand~/.ssh/config(if it exists)?