Search code examples
ubuntusshvirtualboxubuntu-16.04hortonworks-sandbox

Hortonworks SSH issue on Ubuntu: ssh_exchange_identification: Connection closed by remote host


I tried to look into similar questions, but none of the solutions could help my issue.

I am using Hortonworks HDP 2.6.5 sandbox on Virtualbox on Ubuntu 16.04 LTS. The Hortonworks is running and I have the following displayed on VirtualBox:

enter image description here

Following the instructions I used the 4200 port on localhost for ssh with the following command:

ssh [user]@127.0.0.1 -p 4200

which leads me to the following error:

ssh_exchange_identification: Connection closed by remote host

I tried debugging, I get the following log:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 4200.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mahsa/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request

I would appreciate if anyone can help with the issue.

Thanks


Solution

  • The instructions printed in the HDP Sandbox console for SSH access are misleading. Port 4200 is useful for shell access using the HTTP protocol using your browser, and hence doesn't work with command-line ssh. Notice the 'HTTP/1.1 400 Bad Request' error message at the end of your log. Try port 2222 instead as follows:

    prompt> ssh root@localhost -p 2222