配置sshd服務(wù) 在服務(wù)器上修改/etc/ssh/sshd_config:
<!-- lang: shell -->
#禁止root登錄
PermitRootLogin no
#指定可以登錄的用戶
AllowUsers bob alice
StrictModes yes
#關(guān)閉密碼驗(yàn)證
PasswordAuthentication no
#打開RSA驗(yàn)證相關(guān)設(shè)置
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#關(guān)閉 GSSAPI驗(yàn)證
GSSAPIAuthentication no
重啟sshd服務(wù)
生成rsa-keypair 切換到允許ssh登錄的用戶賬戶執(zhí)行如下執(zhí)行如下命令:
<!-- lang: shell -->
#生成key-pair
ssh-keygen
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys
sudo chmod 700 ~/.ssh
restorecon -R -v ~/.ssh
復(fù)制剛剛生成的id_rsa文件到本地,一般命名為:server.pem
ssh -i server.pem username@server






