1. 程式人生 > >ssh 免密碼登錄服務器

ssh 免密碼登錄服務器

touch id_rsa 1.2 user ssh 免密碼登錄 com 登錄 -s 文件

本機生成 ssh key

ssh-keygen -t rsa -C "[email protected]"

上傳公鑰文件(假設用戶為 user,服務器 ip 為 1.2.3.4)

$ scp ~/.ssh/id_rsa.pub [email protected]:~/

ssh 登錄服務器

mkdir ~/.ssh
chmod 700 -R .ssh

touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

cat id_rsa.pub >> ~/.ssh/authorized_keys  #公鑰寫入 authorized_keys

ssh 免密碼登錄服務器