我的mac端(记为A),向谷歌云服务器端:35.230.18.37(记为B),通过ssh公私钥认证登录。
- 在本地A端生成一对公私钥,利用如下的命令:
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是公钥
- 将A的公钥复制到远程服务器B端,过程如下:
- 进入到B的家目录的.ssh下: /home/muzhitaoshi/.ssh
- 创建authorized_keys文件,赋予600权限
- 将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
-
打开filezilla,创建新站点
image.png
密钥文件选择A机的私钥,在连接的时候,会将A的私钥和B的公钥进行匹配,来建立信任
网友评论