SSH的详细安装步骤及登录提示:connection refused的解决办法
2014-06-24 19:01
495 查看
如果出现ssh: connect to host XX.XX.XX.XX port 22: Connection refused
请按如下步骤检查:
1、目标主机的ssh server端程序是否安装、服务是否启动,是否在侦听22端口;
检查方法:
june@ubuntu:~$ ps -ef|grep sshd
root 2859 1 020:29 ? 00:00:00 /usr/sbin/sshd -D
root 2901 2859 020:31 ? 00:00:00 sshd: june[priv]
june 2971 2901 020:31 ? 00:00:00 sshd:june@pts/1
june@ubuntu:~$
其中/usr/sbin/sshd为ssh clinet/server中server端的守护进程,如果上述结果中没有sshd出现,那么可能就是你的server端程序没有安装(Ubuntu 11.04 默认没有安装ssh server,只安装了ssh client),或者sshd服务没有启动,这两者的解决办法请见下文详述。
2、是否允许该用户登录;
3、本机是否设置了iptables规则,禁止了ssh的连入/连出;
检查方法:
june@ubuntu:~$sudo iptables -L
[sudo] password for june:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
june@ubuntu:~$
4、查查ssh的配置文件
ls -lrt /etc/ssh
针对第一点没有安装ssh server或者没开启sshd的用户,可以参考这篇:
Ubuntu如何开启SSH服务
SSH分客户端openssh-client和openssh-server
如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-get install openssh-client),如果要使本机开放SSH服务就需要安装openssh-server:sudo apt-get install openssh-server然后确认sshserver是否启动了:
ps -e |grep ssh
如果看到sshd那说明ssh-server已经启动了。
如果没有则可以这样启动:sudo /etc/init.d/ssh start
ssh-server配置文件位于/etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。
然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
然后使用以下方式登陆SSH:
ssh tuns@192.168.0.100 tuns为192.168.0.100机器上的用户名,需要输入密码。
断开连接:exit
完整过程如下所示:
june@~ 19:57:22>
ssh june@192.168.1.101
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOINGSOMETHING NASTY!
Someone could be eavesdropping on you rightnow (man-in-the-middle attack)!
It is also possible that a host key hasjust been changed.
The fingerprint for the RSA key sent by theremote host is
7f:57:35:cf:23:86:12:cb:e5:51:7a:a3:57:71:15:71.
Please contact your system administrator.
Add correct host key in/home/june/.ssh/known_hosts to get rid of this message.
Offending RSA key in/home/june/.ssh/known_hosts:8
RSA host key for 192.168.1.101 has changedand you have requested strict checking.
Host key verification failed.
june@~ 20:30:55>
june@~ 20:31:36>
rm /home/june/.ssh/known_hosts
june@~ 20:31:46>
ssh june@192.168.1.101
The authenticity of host '192.168.1.101(192.168.1.101)' can't be established.
ECDSA key fingerprint is50:9b:b7:15:c0:57:aa:d6:22:7c:97:40:6e:49:6e:94.
Are you sure you want to continueconnecting (yes/no)? yes
Warning: Permanently added '192.168.1.101'(ECDSA) to the list of known hosts.
june@192.168.1.101's password:
Welcome to Ubuntu 11.04 (GNU/Linux2.6.38-8-generic i686)
*Documentation: https://help.ubuntu.com/
Last login: Sat Jun 25 12:38:24 2011
june@ubuntu:~$
转载地址:http://hi.baidu.com/leejun_2005/item/bfc0ded296cb8ebf32db907e
请按如下步骤检查:
1、目标主机的ssh server端程序是否安装、服务是否启动,是否在侦听22端口;
检查方法:
june@ubuntu:~$ ps -ef|grep sshd
root 2859 1 020:29 ? 00:00:00 /usr/sbin/sshd -D
root 2901 2859 020:31 ? 00:00:00 sshd: june[priv]
june 2971 2901 020:31 ? 00:00:00 sshd:june@pts/1
june@ubuntu:~$
其中/usr/sbin/sshd为ssh clinet/server中server端的守护进程,如果上述结果中没有sshd出现,那么可能就是你的server端程序没有安装(Ubuntu 11.04 默认没有安装ssh server,只安装了ssh client),或者sshd服务没有启动,这两者的解决办法请见下文详述。
2、是否允许该用户登录;
3、本机是否设置了iptables规则,禁止了ssh的连入/连出;
检查方法:
june@ubuntu:~$sudo iptables -L
[sudo] password for june:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
june@ubuntu:~$
4、查查ssh的配置文件
ls -lrt /etc/ssh
针对第一点没有安装ssh server或者没开启sshd的用户,可以参考这篇:
Ubuntu如何开启SSH服务
SSH分客户端openssh-client和openssh-server
如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-get install openssh-client),如果要使本机开放SSH服务就需要安装openssh-server:sudo apt-get install openssh-server然后确认sshserver是否启动了:
ps -e |grep ssh
如果看到sshd那说明ssh-server已经启动了。
如果没有则可以这样启动:sudo /etc/init.d/ssh start
ssh-server配置文件位于/etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。
然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
然后使用以下方式登陆SSH:
ssh tuns@192.168.0.100 tuns为192.168.0.100机器上的用户名,需要输入密码。
断开连接:exit
完整过程如下所示:
june@~ 19:57:22>
ssh june@192.168.1.101
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOINGSOMETHING NASTY!
Someone could be eavesdropping on you rightnow (man-in-the-middle attack)!
It is also possible that a host key hasjust been changed.
The fingerprint for the RSA key sent by theremote host is
7f:57:35:cf:23:86:12:cb:e5:51:7a:a3:57:71:15:71.
Please contact your system administrator.
Add correct host key in/home/june/.ssh/known_hosts to get rid of this message.
Offending RSA key in/home/june/.ssh/known_hosts:8
RSA host key for 192.168.1.101 has changedand you have requested strict checking.
Host key verification failed.
june@~ 20:30:55>
june@~ 20:31:36>
rm /home/june/.ssh/known_hosts
june@~ 20:31:46>
ssh june@192.168.1.101
The authenticity of host '192.168.1.101(192.168.1.101)' can't be established.
ECDSA key fingerprint is50:9b:b7:15:c0:57:aa:d6:22:7c:97:40:6e:49:6e:94.
Are you sure you want to continueconnecting (yes/no)? yes
Warning: Permanently added '192.168.1.101'(ECDSA) to the list of known hosts.
june@192.168.1.101's password:
Welcome to Ubuntu 11.04 (GNU/Linux2.6.38-8-generic i686)
*Documentation: https://help.ubuntu.com/
Last login: Sat Jun 25 12:38:24 2011
june@ubuntu:~$
转载地址:http://hi.baidu.com/leejun_2005/item/bfc0ded296cb8ebf32db907e
相关文章推荐
- ssh 安装及登录提示:connection refused(ssh: connect to host XX.XX.XX.XX port 22: Connection refused)的解决办法
- ssh 安装及登录提示:connection refused的解决办法
- ssh 安装及登录提示:connection refused的解决办法
- ssh 安装及登录提示:connection refused的解决办法
- ssh远程登录服务器时提示'Permission denied (publickey)'的解决办法
- (转)oracle11g安装完成在cmd命令行使用sqlplus登录时提示:ORA-12560: TNS: 协议适配器错误 的解决办法
- K/3 CLOUD登录安装silverlight失败提示1603错误的解决办法。
- linux中mysql安装后,登录提示密码错误,解决办法
- oracle11g安装完成在cmd命令行使用sqlplus登录时提示:ORA-12560: TNS: 协议适配器错误 的解决办法
- Ubuntu中不能使用ssh远程登录的解决办法;ssh服务的安装与配置
- oracle11g安装完成在cmd命令行使用sqlplus登录时提示:ORA-12560: TNS: 协议适配器错误 的解决办法
- SSH Secure Shell Client登录时提示:connection refused的解决办法
- ssh服务安装和登录出现的几种错误以及解决办法
- [解决办法]已经安装了数字证书,但是谷歌浏览器登录https协议的web系统时仍然提示证书不受信任
- 安装oracle时提示Error in CreateOUIProcess(): 13 : Permission denied 的详细解决办法。
- SSH 登录ubuntu server在命令行中按tab键时总是提示LC_CTYPE 相关信息的解决办法
- 安装IE8在控制面板里面删除之后进不去桌面,提示找不到-IESetting.dll 解决办法(解决IE8卸载不了的问题,返回IE7 ,返回IE6),从IE8回到IE7的方法.
- 安装完SQL2000后启动服务器提示“由于登录失败而无法启动服务”解决方法
- Dell1501-光驱启动安装的软件提示Bad Command的解决办法
- crystal report 图像字段处理和提示登录框问题的解决办法