connect to host localhost port 22: Connection refused

If install Hadoop on Mac OSX, make sure turn on Remote Login under System Preferences then File Sharing. This worked on my machine.

Remote Login


  1. Remove SSH with the following command:

    sudo apt-get remove openssh-client openssh-server
    
  2. Install SSH again with:

    sudo apt-get install openssh-client openssh-server
    

It will solve your problem.


Do you have sshd installed? You can verify that with:

which ssh
which sshd

For detailed information you can visit this link.