1

The command below hangs when I attempt to connect to SSH server from Mac OS client. However, it works perfectly fine in Linux env.

$ ssh -vvv [email protected] -p 22

OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/myself/.ssh/config
debug1: /Users/myself/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "172.18.0.2" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 172.18.0.2 [172.18.0.2] port 22.
debug1: connect to address 172.18.0.2 port 22: Operation timed out
ssh: connect to host 172.18.0.2 port 22: Operation timed out

As suggested in many posts, I've unset SSH_AUTH_SOCK env variable but nothing has changed. The SSH server is a Docker container and ports exposed as 0.0.0.0:2222->22/tcp at "Gateway": "172.18.0.1", "IPAddress": "172.18.0.2". See container's SSH and SSHD config details below if it helps.

/etc/ssh/ssh_config

Host *
    HashKnownHosts yes
    GSSAPIAuthentication yes

/etc/ssh/sshd_config

ChallengeResponseAuthentication no
UsePAM no
PrintMotd no
X11Forwarding no
AllowTcpForwarding no
AllowAgentForwarding no
PermitTunnel no

Subsystem sftp internal-sftp
Match Group sftp
    ChrootDirectory %h
    X11Forwarding no
    AllowTcpForwarding no
    AllowAgentForwarding no
    PermitTunnel no
    ForceCommand internal-sftp

I can confirm that the ssh-agent on client OS is running.

$ ssh-agent
SSH_AUTH_SOCK=/var/folders/gw/89swycgx0gqg8g28nfr1x2r80000gn/T//ssh-dF9lR82eJulp/agent.59018; export SSH_AUTH_SOCK;
SSH_AGENT_PID=59019; export SSH_AGENT_PID;
echo Agent pid 59019;

THIS IS VISUAL EXPLANATION OF THE PROBLEM

enter image description here

1
  • 1
    This will always work fine on the machine running Docker. On external machines you will have to use the exposed port, or set up lots of routes to expose all your containers to the wider network (which you probably don't want to do). Aug 10, 2018 at 15:07

1 Answer 1

0

This can be related to a faulty XQuartz. Try and disable X11 forwarding for the host in ~/.ssh/config. I had the exact same issue and changed ForwardX11=yes to ForwardX11=no for all my hosts in ~/.ssh/config.

If this solves the problem, either run without X11 forwarding or get XQuartz fixed.

This was my error:

debug2: client_x11_get_proto: /opt/X11/bin/xauth -f /var/folders/y4/lz_nnc_x7fzxxxkp6q_k7740000gn/T//ssh-KRdxxxxfMNmi/xauthfile generate /private/tmp/com.apple.launchd.oKxxxxYms3/org.macosforge.xquartz:0 MIT-MAGIC-COOKIE-1 untrusted timeout 1260 2>/dev/null
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .