文件位置

  • /etc/ssh/sshd_config

指定端口

Port 22

禁止root(指所有uid为0的用户)用户远程登录

PermitRootLogin no

禁止自定义用户登录

DenyUsers postgres,mysql

只允许白名单用户登录

AllowUsers root

禁止密码登录同时使用秘钥登录

PasswordAuthenticatio no
PubkeyAuthentication yes #默认开启