0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SSH 免密登陆服务器

Posted at

0x01 客户端生成公私钥

$ ssh-keygen

一直按回车即可,生成后会在用户目录下有个 .ssh 的目录,其中包含公钥和私钥

确保客户端,也就是本机已经生成对应密钥,如果没生成,需要先生成

0x02 上传公钥到服务器

$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.55.37.187

运行后输入密码,然后提示一下信息代表成功

Number of key(s) added:        1

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

此时就可以在服务器下看到对应的公钥

[root@VM]$ cat ~/.ssh/authorized_keys   

0x03 测试

$ ssh root@192.55.37.187

运行后成功免密登陆

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?