原文地址
linux sshd公钥及双重验证配置方法
打开配置文件
通常,linux发行版的sshd配置文件路径为/etc/ssh/sshd_config
,使用你喜欢的编辑器打开,非root账户加上sudo,否则权限不够,无法保存!
例如:
sudo vim /etc/ssh/sshd_config
更改端口
更改端口并非必须,但是更改端口可以起到有限的防御作用,所以建议更改!
找到#Port 22
所在行,取消注释,并将22改为你要更改更改的端口。
将端口更改为2222:
Port 2222
修改支持的登录验证方式
密码验证方式
密码验证方式默认开启,如需关闭找到#PasswordAuthentication yes
所在行,取消注释,将yes改为no!
PasswordAuthentication no
然后找到ChallengeResponseAuthentication
,也将其设置为no。
ChallengeResponseAuthentication no
公钥认证方式
公钥验证方式默认开启,证书生成及配置将在后面介绍,如需关闭公钥验证,找到#PubkeyAuthentication yes
所在行,取消注释,将yes改为no!
PubkeyAuthentication no
双重认证
双重认证配置方式将在后面介绍,如需要设置双重认证,请找到ChallengeResponseAuthentication
所在行,