MoonLab - TIL

This is where i store my today-i-learned

You may also wannna visit my blog

Home

服务器配置ssh仅允许使用pubkey验证

本地要有keypair,可以是rsa也可以是ed25519。

$ ssh-keygen

将本地的pubkey复制到服务器的~/.ssh/authorized_keys中:

$ ssh-copy-id username@host

然后修改服务器的ssh服务器配置:

$ sudo nano /etc/ssh/sshd_config
PubkeyAuthentication yes
PasswordAuthentication no
AuthorizedKeysFile      .ssh/authorized_keys
PasswordAuthentication no