CentOS 配置無密碼登錄
配置sshd服務 在服務器上修改/etc/ssh/sshd_config:
<!-- lang: shell -->
#禁止root登錄PermitRootLogin no#指定可以登錄的用戶AllowUsers bob aliceStrictModes yes#關閉密碼驗證PasswordAuthentication no#打開RSA驗證相關設置RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys#關閉 GSSAPI驗證GSSAPIAuthentication no
重啟sshd服務
生成rsa-keypair 切換到允許ssh登錄的用戶賬戶執行如下執行如下命令:
<!-- lang: shell -->
#生成key-pairssh-keygen cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keyssudo chmod 600 ~/.ssh/authorized_keyssudo chmod 700 ~/.sshrestorecon -R -v ~/.ssh
復制剛剛生成的id_rsa文件到本地,一般命名為:server.pem
ssh -i server.pem username@server
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選