0 喜欢

使用SSH密钥登录远程服务器

admin
admin
2022-03-15 14:16:54 阅读 729
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.

复制密钥到远程服务器

$ ssh-copy-id id@server //用户名@服务器地址
id@server's password:

输出结果如下:

$ ssh-copy-id root@服务器地址
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/31325/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@服务器地址's password:

Number of key(s) added: 1

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

检查登录:

ssh id@server

关于作者
admin
admin
admin@ifront.net
 获得点赞 58
 文章阅读量 79822
文章标签