SSH 免密登录

本机生成密钥对

ssh-keygen -t rsa -f ~/.ssh/id_rsa -C "[email protected]"

方式1

#上传公钥到远程主机
scp ~/.ssh/id_rsa.pub [email protected]:/data/

#配置远程主机
cat /data/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

方式2

ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

问题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.

由于之前登录过该台云主机,而主机进行了系统重装导致。
删除known_hosts关于该主机的记录。

你可能感兴趣的:(SSH 免密登录)