<ssh> 2 putty无法连接ubuntu

[b]1.问题描述[/b]
ssh服务安装好后,测试服务也是启动了的。但用putty连接就是不行,直接报错:server unexpectedly closed network connection
然后登陆linux服务器直接测试: ssh localhost也是报错:
read from socket failed connection reset by peer

[b]2.解决办法[/b]
查资料,查看防火墙,查看/etc/ssh/ssh_config都没有问题。在win7上用telnet IP 22测试也没问题。
最后在[url]http://askubuntu.com/questions/308107/cant-ssh-localhost[/url]上看到解答,虽然ssh_config文件没问题,但是/etc/ssh/sshd_config文件是空的。按步骤:
1.Remove the configuration file:
sudo rm /etc/ssh/sshd_config
2.purge:
sudo apt-get purge openssh-server
3.install:
sudo apt-get install openssh-server

完成上面三步再看sshd_config文件就不是空的了。再用service ssh status查看也没问题。

4.用ssh localhost没问题了! 用pietty登陆也没问题。
[color=red]注意:此时都是用的普通用户登陆。用root用户两种方式都不行。用pietty可以先用普通用户登陆然后再切换到root。[/color]

[b]2.1 root登陆[/b]
我们还是想能直接用root用户登陆。可以参考:
[url]https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/V2V_Guide/Preperation_Before_the_P2V_Migration-Enable_Root_Login_over_SSH.html[/url]

Enable root login over SSH:
As root, edit the sshd_config file in /etc/ssh/sshd_config:
vi /etc/ssh/sshd_config

(1)Add a line in the Authentication section of the file that says PermitRootLogin yes. This line may already exist and be commented out with a "#". In this case, remove the "#".

# Authentication:
#LoginGraceTime 2m
[color=red] PermitRootLogin yes[/color]
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

(2)Save the updated /etc/ssh/sshd_config file.
(3)Restart the SSH server:
(4)service ssh restart // 这个事ubuntu,其他linux可能是service sshd restart
好了,测试通过。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值