1.生成密鑰:
在SecureCRT建立私鑰和公鑰:
主菜單->工具->建立公鑰->選擇RSA->私鑰密碼不填>密鑰長度填為1024->點選完成,生成兩個檔案,預設名為identity和identity.pub
2.把私鑰和公鑰轉換為OpenSSH格式:
主菜單->工具->轉換私鑰到OpenSSH格式->選擇剛生成私鑰檔案identity->生成兩個檔案,指定為id_rsa, id_rsa.pub
2.密鑰配置:
① id_rsa,id_rsa.pub 上傳伺服器,拷貝到/root/.ssh/目錄下
#cp id_rsa /root/.ssh/ cp id_rsa.pub /root/.ssh/
②建立authorized_keys檔案
# touch /root/.ssh/authorized_keys (如果已經存在這個檔案, 跳過這條)
③追加公鑰到authorized_keys2中
# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys (将id_rsa.pub的内容追加到 authorized_keys 中)
④改變id_rsa檔案權限
#chmod 700 /root/.ssh/id_rsa
3.SSH證書登陸驗證
# ssh root@IP (因為沒有設定私鑰密碼, 是以不需要密碼, 登入成功)
4.關閉SSH密碼登陸
編輯 SSH 配置檔案:
vim /etc/ssh/sshd_config
#PasswordAuthentication yes (yes改為no)
儲存,退出,