ssh公私钥认证

2019-07-10  本文已影响0人  低级bug制造专家

我的mac端(记为A),向谷歌云服务器端:35.230.18.37(记为B),通过ssh公私钥认证登录。

ssh keygen 
xihua-MacBook-Pro:.ssh liuxun$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/liuxun/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/liuxun/.ssh/id_rsa.
Your public key has been saved in /Users/liuxun/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:dXD5sGnbPOH1mlN7OvrVNHBitH03muv8OHzOjkyvRXs liuxun@xihua-MacBook-Pro.local
The key's randomart image is:
+---[RSA 2048]----+
|          . .o   |
|           o+ o  |
|          . .X +o|
|         . .= O =|
|        S  . B =o|
|            . B.*|
|            .o BE|
|            =o@+o|
|            .XXX.|
+----[SHA256]-----+
xihua-MacBook-Pro:.ssh liuxun$ ls
id_rsa      id_rsa.pub  known_hosts

id_rsa是私钥,id_rsa.pub是公钥

  1. 进入到B的家目录的.ssh下: /home/muzhitaoshi/.ssh
  2. 创建authorized_keys文件,赋予600权限
  3. 将A主机的公钥复制到B的authorized_keys文件中
muzhitaoshi@tensorflow-2-vm:~/.ssh$ ls
known_hosts
muzhitaoshi@tensorflow-2-vm:~/.ssh$ touch authorized_keys
muzhitaoshi@tensorflow-2-vm:~/.ssh$ ls
authorized_keys  known_hosts
muzhitaoshi@tensorflow-2-vm:~/.ssh$ sudo chmod 600 authorized_keys 
muzhitaoshi@tensorflow-2-vm:~/.ssh$ vim authorized_keys 
上一篇下一篇

猜你喜欢

热点阅读