Getting connection reset when trying to ssh localhost

26,810

Try regenerating the host keys:

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

You can get more debug information from ssh with the -v option, as well as looking in the ssh server log, for debian/ubuntu, this is /var/log/auth.log

Share:
26,810
Shane Ekanayake
Author by

Shane Ekanayake

Updated on September 18, 2022

Comments

  • Shane Ekanayake
    Shane Ekanayake over 1 year

    I installed openssh using below command

    apt-get install openssh-server openssh-client
    

    I'm trying to create ssh connection to localhost.

    ssh user@localhost
    

    I'm getting below error

    Connection reset by 127.0.0.1 port 22
    

    How to resolve this error?

  • HowlingFantods
    HowlingFantods almost 6 years
    I have seen this suggestion elsewhere, but am confused, is this command supposed to be run on the host machine or client? Am I just out of luck if ssh is my only means of accessing the host?
  • Andrew Domaszek
    Andrew Domaszek almost 6 years
    It needs to be done on the host server. You'll need some other way to get remote access if ssh is currently inoperable. kvm-over-ip, ipmi console, or rescue boot disk all come to mind.
  • Rakete1111
    Rakete1111 almost 5 years
    You can also use ssh-keygen -A -f / to regenerate the host keys.