Linux ssh免密登陆

94 阅读1分钟

1,在本地生成ssh公钥

ssh-keygen -t rsa

2,使用ssh-copy-id -i上传公钥到服务器

ssh-copy-id -i ~/.ssh/ id_rsa.pub user@localhost

成功会输出信息

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'user@localhost'"
and check to make sure that only the key(s) you wanted were added.

再通过ssh user@host 即可免密登陆

本文参考: Linux下实现免密码登录(超详细)