[实践OK]CentOS7默认不让Root登录/FreeBSD装好后,如何让root用户能直接进行ssh登录以及配置密钥方法,freeBSD 让root ssh登陆, vi /etc/ssh/sshd_config,PermitRootLogin yes。
centos 7 禁止root直接登录系统,FreeBSD出于安全原因,默认参数很严格,禁止root用户直接使用ssh登陆
比如先用非root的帐户,登陆到ssh后,su成为root
如果想直接用root登陆,则修改如下配置文件:
vi /etc/ssh/sshd_config #是sshd_config得有个d,不是这个:/etc/ssh/ssh_config,是这个/etc/ssh/sshd_config
找到其中的如下一行,将前边的#符号去掉,并修改no为yes
#PermitRootLogin no
改成:
PermitRootLogin yes
接下来执行如下命令重新启动SSH服务:
xxx# /etc/rc.d/sshd restart
Stopping sshd.
Waiting for PIDS: 349.
Starting sshd.
xxx#
重新启动完成后,ssh即可登陆。
有可能要重新启动一下,reboot,我有次就重新启动可以ssh进去。AddTime:2016-01-10
service sshd restart
ps -ef|grep sshd
root 49624 1 0 17:14 ? 00:00:00 /usr/sbin/sshd
____________________________________________________________________________
开启SSH服务
(1)ee /etc/inetd.conf #编辑,去掉sshd前面的#
ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4
(2)ee /etc/rc.conf #编辑,在最后添加
sshd_enable="yes"
(3)ee /etc/ssh/sshd_config #编辑配置文件
PermitRootLogin yes #允许root登录
PasswordAuthentication yes #使用密码验证
PermitEmptyPasswords no #不允许空密码登录
/etc/rc.d/sshd start #启动ssh服务
/etc/rc.d/sshd restart #重启ssh
http://www.osyunwei.com/archives/3007.html
____________________________________________________________________________
1 在FreeBSD中执行
ssh-keygen -t dsa
可得到
/home/leakon/.ssh/id_dsa
/home/leakon/.ssh/id_dsa.pub
2 可以用 WinSCP 下载这个两个文件到本地,保存到
C:\Documents and Settings\leakon\Application Data\VanDyke\
这是 SecureCRT 在 Windows 的 leakon 用户的程序数据文件夹中生成的目录
我保存到:D:\ssh_tmp\freeBSD_Key_Login
3 打开会话选项,在 分类 中选择 SSH2,在右边的 身份验证 中选择 公钥(PublicKey),然后点击旁边的 属性(Properites),选择 使用会话公钥设置(注意:会话公钥)(Use session public key setting),在 使用身份文件(Use identify file) 的输入框中,选择刚才下载回来的 id_dsa,注意,id_dsa 和 id_dsa.pub 要保存在一起(两个文件取名任意,但必须符合 somekey 和 somekey.pub)
4 按照 /etc/ssh/sshd_config 中指定的公钥文件名 AuthorizedKeysFile .ssh/authorized_keys,修改本地公钥文件名,在FreeBSD中执行
cd /home/leakon/.ssh/
mv id_dsa.pub authorized_keys 另外一个id_dsa可以不动它。
至此,方法一大功告成,重新用 SecureCRT 连接一下试试,直接就登录好了吧
比如先用非root的帐户,登陆到ssh后,su成为root
如果想直接用root登陆,则修改如下配置文件:
vi /etc/ssh/sshd_config #是sshd_config得有个d,不是这个:/etc/ssh/ssh_config,是这个/etc/ssh/sshd_config
找到其中的如下一行,将前边的#符号去掉,并修改no为yes
#PermitRootLogin no
改成:
PermitRootLogin yes
接下来执行如下命令重新启动SSH服务:
xxx# /etc/rc.d/sshd restart
Stopping sshd.
Waiting for PIDS: 349.
Starting sshd.
xxx#
重新启动完成后,ssh即可登陆。
有可能要重新启动一下,reboot,我有次就重新启动可以ssh进去。AddTime:2016-01-10
service sshd restart
ps -ef|grep sshd
root 49624 1 0 17:14 ? 00:00:00 /usr/sbin/sshd
____________________________________________________________________________
开启SSH服务
(1)ee /etc/inetd.conf #编辑,去掉sshd前面的#
ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4
(2)ee /etc/rc.conf #编辑,在最后添加
sshd_enable="yes"
(3)ee /etc/ssh/sshd_config #编辑配置文件
PermitRootLogin yes #允许root登录
PasswordAuthentication yes #使用密码验证
PermitEmptyPasswords no #不允许空密码登录
/etc/rc.d/sshd start #启动ssh服务
/etc/rc.d/sshd restart #重启ssh
http://www.osyunwei.com/archives/3007.html
____________________________________________________________________________
1 在FreeBSD中执行
ssh-keygen -t dsa
可得到
/home/leakon/.ssh/id_dsa
/home/leakon/.ssh/id_dsa.pub
2 可以用 WinSCP 下载这个两个文件到本地,保存到
C:\Documents and Settings\leakon\Application Data\VanDyke\
这是 SecureCRT 在 Windows 的 leakon 用户的程序数据文件夹中生成的目录
我保存到:D:\ssh_tmp\freeBSD_Key_Login
3 打开会话选项,在 分类 中选择 SSH2,在右边的 身份验证 中选择 公钥(PublicKey),然后点击旁边的 属性(Properites),选择 使用会话公钥设置(注意:会话公钥)(Use session public key setting),在 使用身份文件(Use identify file) 的输入框中,选择刚才下载回来的 id_dsa,注意,id_dsa 和 id_dsa.pub 要保存在一起(两个文件取名任意,但必须符合 somekey 和 somekey.pub)
4 按照 /etc/ssh/sshd_config 中指定的公钥文件名 AuthorizedKeysFile .ssh/authorized_keys,修改本地公钥文件名,在FreeBSD中执行
cd /home/leakon/.ssh/
mv id_dsa.pub authorized_keys 另外一个id_dsa可以不动它。
至此,方法一大功告成,重新用 SecureCRT 连接一下试试,直接就登录好了吧
作者:jackx@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://www.jackxiang.com/post/802/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackx 编辑于2018-3-21 17:15
http://blog.sina.com.cn/s/blog_6a4010f50100k11g.html
有详细说明