Getting this error while accessing ssh configured on MAC OSX
ssh exchange identification connection closed by remote host
Solution:
Go to System preferences – Sharing and enable remote login
Option is there to allow everybody to access through ssh else allow
specific users.
Turn OFF and turn it ON again and see if you are able to connect through
ssh
I could get exact error on system.log file
Open terminal #sudo tail -f /var/log/system.log
Feb 19 14:38:48 devsrv.local WindowServer[200]:
CGXRegisterWindowWithSystemStatusBar: window 17 already registered
Feb 19 14:39:18 devsrv.local sshd[1086]: fatal: /var/empty must be owned
by root and not group or world-writable.
Feb 19 14:39:27 devsrv.local sshd[1088]: fatal: /var/empty must be owned
by root and not group or world-writable.
It’s something permission related issue where /var/empty folder is not writable by root which was stopping to run ssh service
Open terminal #sudo chmod 755 /var/empty
You can do a reboot of the MAC OSX and you should be able to connect
through SSH without any error.
“ssh_exchange_identification: Connection closed by remote host”
You may also like: Install and configure Jasper Report Server on Ubuntu Server
Odd that in my case, I tried it before I left home, using a WAN address, which I thought would have shown any firewall/permission problems. I even turned off Little Snitch. Then when I got to my remote location, I get that error.
Good find. I also saw in my case that /var/empty was not owned by root so I had to also do chown root /var/empty.
Thanks man, the Remote Login thing worked. I have a process that’s worked for years, where I ssh from my mac, to my remote Linux server. A reverse port is opened in the process, and then from the remote host, I can ssh (or scp) back into the mac, without further identification. Very handy for my scripts. But then it stopped working after some system settings were lost in a hardware upgrade.
I guess I must have enabled this at some point in the past, but I forgot. So, thank you!
Thanks Joe, Glad to know that it worked!