SSh: Connection refused to localhost
45,387
Solution 1
Don't panic! Your command is incorrect.
ssh -vvv localhost -p 8047
The parameter -p 8047
means to reach port 8047, however SSH daemon runs at port 22. The config of sshd you pasted, has already proven my assumption.
You can try to access localhost via SSH by using
ssh hduser@localhost
Solution 2
you need to install openssh server
sudo apt-get install openssh-server
Author by
ridvanzoro
Updated on September 26, 2020Comments
-
ridvanzoro over 3 years
I want to install hadoop to ubuntu.
I'm following this tutorial: Running Hadoop on Ubuntu Linux
But i am facing a problem at step
ssh localhost
hduser@r:~$ ssh -vvv localhost -p 8047 OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to localhost [127.0.0.1] port 8047. debug1: connect to address 127.0.0.1 port 8047: Connection refused ssh: connect to host localhost port 8047: Connection refused hduser@r:~$ which ssh /usr/bin/ssh hduser@r:~$ which sshd hduser@r:~$
This is my /etc/ssh/sshd_config:
last 5 lines added only!
# Package generated configuration file # See the sshd_config(5) manpage for details # What ports, IPs and protocols we listen for Port 22 # Use these options to restrict which interfaces/protocols sshd will bind to #ListenAddress :: #ListenAddress 0.0.0.0 Protocol 2 # HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key #Privilege Separation is turned on for security UsePrivilegeSeparation yes # Lifetime and size of ephemeral version 1 server key KeyRegenerationInterval 3600 ServerKeyBits 768 # Logging SyslogFacility AUTH LogLevel INFO # Authentication: LoginGraceTime 120 PermitRootLogin yes StrictModes yes RSAAuthentication yes PubkeyAuthentication yes #AuthorizedKeysFile %h/.ssh/authorized_keys # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #IgnoreUserKnownHosts yes # To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Change to no to disable tunnelled clear text passwords #PasswordAuthentication yes # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes #UseLogin no #MaxStartups 10:30:60 #Banner /etc/issue.net # Allow client to pass locale environment variables AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. UsePAM yes AllowGroups hduser # disable ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
thanks in advance (and also for not voting down :D ) )
EDIT:
hduser@r:~$ r@r:~$ netstat -tulpn tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:17500 0.0.0.0:* LISTEN - udp 0 0 127.0.1.1:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 0.0.0.0:17500 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp 0 0 0.0.0.0:26575 0.0.0.0:* - udp 0 0 0.0.0.0:47235 0.0.0.0:* - -
-
ridvanzoro about 10 yearsI update my question and add result of netstat -tulpn
-
SS781 about 10 yearsThe output of netstat shows which services are listening on which ports. Your posted output shows that there is nothing listening on port 8047, so it makes sense that you are getting a Connection refused error. If you really want to connect through that port, you need to have your sshd listen on it.
-
ridvanzoro about 10 yearsI know
-p 8047
is wrong. Butssh hduser@localhost
helped me to find problem.It givesOffending ECDSA key in /home/hduser/.ssh/known_hosts:1 remove with: ssh-keygen -f "/home/hduser/.ssh/known_hosts" -R localhost
. Then it is working afterssh-keygen -f "/home/hduser/.ssh/known_hosts" -R localhost
command.