linux 服务器 ssh root用户免密远程或者本地访问配置

1. 容许root用户远程登陆安全

修改ssh服务配置文件服务器

sudo vi /etc/ssh/sshd_config

调整PermitRootLogin参数值为yes,以下图:ssh

2. 容许无密码登陆rest

同上,修改ssh服务配置文件,两种状况:blog

1) 将PermitEmptyPasswords yes前面的#号去掉it

2) 将PermitEmptyPasswords 参数值修改成yes,以下图:io

不管哪一种,最后PermitEmptyPasswords参数值为yes登录

以上两种配置,均须要重启ssh服务扩展

service sshd restart  # 或者
/etc/initd.d/sshd restart

扩展:配置

为了安全起见,FreeBSD默认状况下是不容许root用户进行SSH远程登陆的,须要进行如下操做才能够进行Root用户的ssh远程登陆。

首先vi编辑/etc/inetd.conf,去掉ssh前的#注释,保存后:wq退出 (开启监听ssh服务)

编辑/etc/rc.conf, 最后加入:sshd_enable=”yes”便可
激活sshd服务:

#/etc/rc.d/sshd start

检查服务是否启动,在22端口应该有监听。

# check port number 22
#netstat -an # 或
#netstat -tnlp

最后,编辑ssh配置文件

#vi  /etc/ssh/sshd_config

在/etc/ssh/sshd_config最后中加入

PermitRootLogin yes #容许root登陆
PermitEmptyPasswords no #不容许空密码登陆
PasswordAuthentication yes # 设置是否使用口令验证。

修改完配置文件后,从新启动sshd服务器(/etc/rc.d/sshd restart)便可。

补充:

1. 若是重启后仍是不行, 请从新载入sshd_config 文件

/etc/rc.d/sshd reload

2. 若是出现using keyboard-interactive authentication
password:
请确认配置文件中,PasswordAuthentication参数值是否已经改为yes
另外若是客户端是putty, 那么请确认”尝试’智能键盘’认证(SSH-2)”的勾是否有去掉!!!!
3. 若是是使用root账号登录
请确认密码是否为空
空密码没法登录
4. 请确认是否有安装SSH
确认sysinstall>>>configure>>>networking>>>sshd是否的勾是否有打上.

ssh服务的一些状态查看

1,查看状态:

systemctl status sshd.service

2,启动服务:

systemctl start sshd.service

3,重启服务:

systemctl restart sshd.service

4,开机自启:

systemctl enable sshd.service
相关文章
相关标签/搜索