ssh: connect to host localhost port 22: Connection refused 问题
2012年10月11日 ⁄ 综合 ⁄ 共 388字 ⁄ 字号 小 中 大 ⁄ 评论关闭
命令:ssh localhost
错误信息:ssh: connect to host localhost port 22: Connection refused
错误原因:
1.sshd 未安装
2.sshd 未启动
3.防火墙
4需重新启动ssh 服务
解决方法:
1.确定安装sshd:
$ sudo apt-get install openssh-server
2.启动sshd:
master@master-VirtualBox:~$ sudo /etc/init.d/ssh start
master@master-VirtualBox:~$ ps -e |grep ssh
3.检查防火墙设置,关闭防火墙:
$ sudo ufw disable
检验方法:
输入命令:
$ ssh localhost
若成功,则表示安装成功,且连接通过;
但是有的时候虽然成功了但是还是会出现Connection refused 问题。
运行 ps -e | grep ssh,查看是否有sshd进程:
有时候虽然可以看到sshd 但是还是不能连接成功
这时候就要想到重新启动一下:sudo service ssh restart
然后在连接
命令:
master@master-VirtualBox:~$ ssh-keygen -t rsa -P ""
master@master-VirtualBox:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
master@master-VirtualBox:~$ cd .ssh/
master@master-VirtualBox:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub
master@master-VirtualBox:~/.ssh$ cd ..
master@master-VirtualBox:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 14:59:96:9d:8c:26:06:f4:f6:cf:6d:59:7f:69:ef:f8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86_64)
* Documentation: https://help.ubuntu.com/
86 packages can be updated.
86 updates are security updates.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
master@master-VirtualBox:~$ exit
logout
Connection to localhost closed.
2012年10月11日 ⁄ 综合 ⁄ 共 388字 ⁄ 字号 小 中 大 ⁄ 评论关闭
命令:ssh localhost
错误信息:ssh: connect to host localhost port 22: Connection refused
错误原因:
1.sshd 未安装
2.sshd 未启动
3.防火墙
4需重新启动ssh 服务
解决方法:
1.确定安装sshd:
$ sudo apt-get install openssh-server
2.启动sshd:
master@master-VirtualBox:~$ sudo /etc/init.d/ssh start
master@master-VirtualBox:~$ ps -e |grep ssh
3.检查防火墙设置,关闭防火墙:
$ sudo ufw disable
检验方法:
输入命令:
$ ssh localhost
若成功,则表示安装成功,且连接通过;
但是有的时候虽然成功了但是还是会出现Connection refused 问题。
运行 ps -e | grep ssh,查看是否有sshd进程:
有时候虽然可以看到sshd 但是还是不能连接成功
这时候就要想到重新启动一下:sudo service ssh restart
然后在连接
命令:
master@master-VirtualBox:~$ ssh-keygen -t rsa -P ""
master@master-VirtualBox:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
master@master-VirtualBox:~$ cd .ssh/
master@master-VirtualBox:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub
master@master-VirtualBox:~/.ssh$ cd ..
master@master-VirtualBox:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 14:59:96:9d:8c:26:06:f4:f6:cf:6d:59:7f:69:ef:f8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86_64)
* Documentation: https://help.ubuntu.com/
86 packages can be updated.
86 updates are security updates.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
master@master-VirtualBox:~$ exit
logout
Connection to localhost closed.