ssh: connect to host localhost port 22: Connection refused
时间: 2023-10-12 19:11:46 浏览: 218
This error message typically occurs when the SSH service is not running on the localhost or the port 22 is not open on the firewall.
To resolve this issue, you can try the following:
1. Check if the SSH service is running on the localhost using the following command:
```
systemctl status sshd
```
If the service is not running, start it using the following command:
```
sudo systemctl start sshd
```
2. Check if the port 22 is open on the firewall using the following command:
```
sudo ufw status
```
If the port is not open, allow it using the following command:
```
sudo ufw allow 22/tcp
```
3. If you are trying to connect to a remote server, make sure that the SSH service is running on the remote server and the port is open on the firewall.
If the above steps do not resolve the issue, you may need to check the SSH configuration and logs for any errors.
阅读全文