Linux设置口令登陆开启和关闭
本文介绍一些实用的Linux设置或关闭口令登录。
请各位用户按照自身需求选择对应的命令。
博客小编也会不定时更新本文的链接和内容。
Linux设置口令登陆
更改root密码
passwd root
设置启动密码认证
sed -ri ‘s/^#?(PasswordAuthentication)\s+(yes|no)/\1 yes/‘ /etc/ssh/sshd_config
设置允许root账号登陆
sed -ri ‘s/^#?(PermitRootLogin)\s+(yes|no|prohibit-password)/\1 yes/‘ /etc/ssh/sshd_config
设置关闭公私密钥登陆只启用口令登陆
(需要设置密钥和口令并存跳过)
sed -ri ‘s/^#?(PubkeyAuthentication)\s+(yes|no)/\1 no/‘ /etc/ssh/sshd_config
重启ssh服务
service sshd restart
Linux关闭口令登陆
设置取消密码认证
sed -ri ‘s/^#?(PasswordAuthentication)\s+(yes|no)/\1 no/‘ /etc/ssh/sshd_config
设置不允许root账号登陆
sed -ri ‘s/^#?(PermitRootLogin)\s+(yes|no|prohibit-password)/\1 no/‘ /etc/ssh/sshd_config
设置开启公私密钥登陆关闭口令登陆
sed -ri ‘s/^#?(PubkeyAuthentication)\s+(yes|no)/\1 yes/‘ /etc/ssh/sshd_config
重启ssh服务
service sshd restart
ssh配置文件位置
/etc/ssh/sshd_config