开启ssh------解决远程登录失败的问题

有的时候别人可能登录不上你的电脑或者无法登录到服务器,最可能出现的问题就是ssh出现了问题。


[root@zong_pc zong]# /etc/init.d/sshd status      //在linux下查看ssh的状态
openssh-daemon (pid  2309) 正在运行...
[root@zong_pc zong]# 

[root@zong_pc zong]# /etc/init.d/sshd start       //若是ssh处于关闭状态,则可以手动开启服务
 

[root@zong_pc /]# /etc/init.d/sshd close
用法: /etc/init.d/sshd {start|stop|restart|reload|force-reload|condrestart|try-restart|status}
[root@zong_pc /]# /etc/init.d/sshd stop
停止 sshd:                                                [确定]
[root@zong_pc /]# /etc/init.d/sshd status
openssh-daemon 已停
[root@zong_pc /]# /etc/init.d/sshd start
正在启动 sshd:                                            [确定]
[root@zong_pc /]# /etc/init.d/sshd stop
停止 sshd:                                                [确定]
[root@zong_pc /]# 

可以直接按以下方法操作:

vim /etc/ssh/sshd_config        
截的部分代码: 
 39 # Authentication:
 40 
 41 #LoginGraceTime 2m
 42 PermitRootLogin no          
 43 #StrictModes yes
 44 #MaxAuthTries 6
 45 #MaxSessions 10
 46

若PermitRootLogin后的参数为no,则会出现这样的提示:
[root@zong_pc ssh]# ssh 192.168.40.223
ssh: connect to host 192.168.40.223 port 22: No route to host




具体步骤总结::
因此,只需将其后的参数改为yes就可以了。PermitRootLogin  yes
修改完成后,
先打开ssh:/etc/init.d/sshd start
然后ssh需要重新启动 /etc/init.d/sshd restart
 

当然,也可能出现下面这种情况:

[root@localhost zhangna]# ssh 192.168.40.22
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
8b:d9:17:7d:97:d5:19:02:a1:27:9f:cc:b8:31:20:34.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for 192.168.40.22 has changed and you have requested strict checking.
Host key verification failed.
[root@localhost zhangna]# rm -rf /root/.ssh/known_hosts
 [root@localhost zhangna]# ssh 192.168.40.22
The authenticity of host '192.168.40.22 (192.168.40.22)' can't be established.
RSA key fingerprint is 8b:d9:17:7d:97:d5:19:02:a1:27:9f:cc:b8:31:20:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.40.22' (RSA) to the list of known hosts.
Address 192.168.40.22 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
root@192.168.40.22's password: 
Last login: Wed Jan 13 10:46:24 2016 from 192.168.40.222
[root@localhost ~]# 


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
通过使用ssh命令的-vvv选项,可以启用详细调试输出,以帮助确认SSH连接失败问题。以下是一些步骤和可能的原因: 1. 打开终端或命令提示符,并输入以下命令: ``` ssh -vvv user@hostname ``` 其中,user是您要连接的远程主机的用户名,hostname是远程主机的IP地址或域名。 2. 运行命令后,您将看到大量的调试输出。这些输出将显示SSH连接的详细信息,包括连接过程中的每个步骤和可能的错误。 3. 仔细检查输出,特别关注以下几个方面: - 验证远程主机的IP地址或域名是否正确。 - 确保远程主机正在运行SSH服务器,并且SSH服务已正确配置。 - 检查本地主机和远程主机之间的网络连接是否正常。 - 检查本地主机和远程主机之间的防火墙设置,确保SSH流量被允许通过。 4. 根据输出中的错误消息或警告,尝试解决问题。常见的问题包括: - 远程主机拒绝连接:可能是由于SSH服务未启动、防火墙阻止了连接或者远程主机上的SSH配置错误。 - 密钥验证失败:可能是由于本地或远程主机上的SSH密钥配置错误、权限问题或者密钥文件损坏。 - 网络连接问题:可能是由于网络故障、路由问题或者防火墙阻止了SSH流量。 请注意,以上只是一些常见的问题解决方法,具体情况可能因系统配置和网络环境而异。如果您仍然无法解决问题,请提供更多详细的错误信息,以便进一步帮助您诊断和解决SSH连接问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值