0%

限制服务器登录:只能本机SSH公钥进行登录指定用户

2019年12月14日 下午10:25

Linux服务器的初步配置流程 - 阮一峰的网络日志

  1. 新建用户
  2. SSH设置(重点)

禁止root用户登录,以及禁止用密码方式登录

注:在配置文件的末尾,指定允许登陆的用户

  1. sudo cp /etc/ssh/sshd_config ~
  2. sudo nano /etc/ssh/sshd_config
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Protocol 2

    PermitRootLogin no
    PermitEmptyPasswords no
    PasswordAuthentication no

    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys

    UseDNS no

    AllowUsers bill