ssh: connect to host localhost port 22: Connection refused
时间: 2023-11-11 08:42:36 浏览: 136
This error message typically indicates that the SSH service is not running on the local system or that the port is blocked by a firewall. Here are some possible solutions:
1. Check if the SSH service is running on your system. You can do this by running the command "sudo service ssh status" on Ubuntu or "systemctl status sshd.service" on CentOS. If the service is not running, start it with "sudo service ssh start" or "systemctl start sshd.service".
2. Check if the SSH port (port 22) is blocked by a firewall. You can check this by running the command "sudo ufw status" on Ubuntu or "firewall-cmd --list-all" on CentOS. If the port is blocked, you can open it with "sudo ufw allow 22" or "firewall-cmd --add-port=22/tcp --permanent" (followed by "firewall-cmd --reload" to apply the changes).
3. If you're trying to connect to SSH from a remote system, make sure that the SSH server is configured to allow remote connections. You can check this by editing the SSH configuration file (/etc/ssh/sshd_config) and verifying that the "ListenAddress" and "Port" directives are set correctly.
4. If none of the above solutions work, try restarting both the SSH service and the system itself. Sometimes a simple restart can resolve connection issues.
阅读全文