本機生成密鑰對
ssh-keygen -t rsa -f ~/.ssh/id_rsa -C "xxxx@163.com"
方式1
#上傳公鑰到遠程主機
scp ~/.ssh/id_rsa.pub root@139.199.xx.xx:/data/
#配置遠程主機
cat /data/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
方式2
ssh-copy-id -i ~/.ssh/id_rsa.pub root@139.199.xx.xx
問題1
ssh-copy-id方式報錯如下:
ERROR: @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the ECDSA key sent by the remote host is
ERROR: SHA256:Hl/dKT2FzL4lOlF8DI2OAsZunC22AWlFGLjLfsg.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /Users/xxx/.ssh/known_hosts to get rid of this message.
ERROR: Offending ECDSA key in /Users/xxx/.ssh/known_hosts:292
ERROR: ECDSA host key for x.x.x.x has changed and you have requested strict checking.
ERROR: Host key verification failed.
由于之前登錄過該臺云主機,而主機進行了系統(tǒng)重裝導致课兄。
刪除known_hosts關于該主機的記錄。