OS X : SSH over Shadowsocks error : "ssh_exchange_identification: Connection closed by remote host"

0

I am in China and SSH connections are slowed down by the Chinese Great Firewall. It is often times so bad that using ssh is just not possible. Thus, I need to tunnel my ssh traffic through shadowsocks to make it undetectable by the CGF. Therefore I added the following lines to my ~/.ssh/config file:

$cat ~/.ssh/config
Host ssserver
  User ubuntu
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

Now, when running ssh -v ssserver I get the following error message:

$ ssh -v ssserver
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/Tom/.ssh/config
debug1: /Users/Tom/.ssh/config line 6: Applying options for ssserver
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug1: Executing proxy command: exec nc -X 5 -x 127.0.0.1:1080 ssserver 22
debug1: identity file /Users/Tom/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Tom/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: permanently_drop_suid: 501
ssh_exchange_identification: Connection closed by remote host

Unfortunately, I am not an SSH expert. So, does anybody know what this means and how to repair this. That would help me really a lot. Thanks.

toom

Posted 2018-10-29T08:03:51.703

Reputation: 101

Answers

0

I found out how to repair the issue. However, it actually leaves me with a new question.

First the solution: By coincidence I found out that replacing the host name from /etc/hosts namely ssserver with it's ip address works. So, I changed the entry in the ~/.ssh/config from the above to:

$cat ~/.ssh/config
Host 64.10.18.222
  User ubuntu
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand nc -x 127.0.0.1:1080 %h %p

Now, on the console I just have to call ssh -v 64.10.18.222 and it works.

Alternatively the full console command is:

ssh -v -i ~/.ssh/your_id_key_file_rsa -o ProxyCommand='nc -x 127.0.0.1:1080 %h %p' ubuntu@64.10.18.222

So, my new question: Why does the IP address work while the hostname taken as in /etc/hosts fails?

toom

Posted 2018-10-29T08:03:51.703

Reputation: 101