ssh_exchange_identification: Connection closed by remote host

If you are unable to connect and get this error:

# ssh -v user@remote.host
ERROR: ssh_exchange_identification: Connection closed by remote host

To get more info about error you might try to add verbose command:

# ssh -v user@remote.host

Check if you user has shell assigned:

# cat /etc/passwd |grep jenkins
jenkins:x:1002: 1002 :Jenkins Automation Server:/var/lib/jenkins:/bin/false

We can see shell is not allowed so change it:

# chsh jenkins
Changing shell for jenkins.
New shell [/bin/bash]: /bin/sh

Now create keys with ssh-keygen and copy them with ssh-copy-id command.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.