Tag Archives: (ssh: connect to host localhost port 22: Connection refused)

SSH Error: (ssh: connect to host localhost port 22: Connection refused)

SSH: connect to host localhost port 22: connection reused

1.Problem description

I used to use the pagoda panel on the service before, but today I had a whim to use the pagoda panel on my computer. (the pagoda panel is really easy to use, especially for my ZZ little white)… But after installing the pagoda panel, when I started the terminal of the panel, I found that when I entered the SSH user name and password, there was no response, and the password and account number were clearly right

some people may want to ask, you TM use the pagoda panel on this machine, but also use the terminal of the pagoda, isn’t it unnecessary,, emmm is indeed, but I just like to do too much… Now that I find this problem, let’s try how to solve it

2. Problem solving

the possible reasons are: the port is not opened, the local firewall refuses, and the local machine has no SSH service

finally, the problem is that there is no SSH service on this machine, right! No, SSH is often used when you use Linux, but this machine may not have SSH service, so we need to install SSH service

generate SSH secret key

$ ssh-keygen -t rsa (Press enter evenly to generate the secret key)

$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

install openssh server (take Ubuntu operating system as an example)

$ sudo apt install openssh-server
 $ sudo /etc/init.d/ssh start 

Test

$ ps -ef | grep ssh(View sshd process)
 $ ssh 127.0.0.1

3. Success:

as shown in the figure:

if you have any questions, please leave a message, and you will help solve them when you see them