創(chuàng)建密鑰
# 首先在本機(jī)上創(chuàng)建 SSH KEY 密鑰對:
$ ssh-keygen # -t 加密方式
$ ssh-keygen -t RSA -b 4096 # RSA密鑰默認(rèn)長度是2048
上傳密鑰
# 將id_rsa.pub密鑰上傳至服務(wù)器中
# 方式一:
$ ssh-copy-id username@remote-server
# 方式二:
# 若服務(wù)器端沒有.ssh目錄,需要手動創(chuàng)建:
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
# 將id_rsa.pub復(fù)制到authorized_keys中
$ scp ~/.ssh/id_rsa.pub root@remote-server: ~/.ssh
# 以上scp命令遠(yuǎn)程拷貝命令
# 公鑰追加到授權(quán)KEY里面
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者