在我的MBP2017上,以连接lonestar5服务器为例

>> ssh-keygen -t rsa
# 生成本机公钥、私钥
Generating public/private rsa key pair.
# 一路回车
Enter file in which to save the key (/Users/yao/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/yao/.ssh/id_rsa.
Your public key has been saved in /Users/yao/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HKagBpNEY2Pk****0ejEu6RGHDB4Ohu8EJ+Y65ivQSg yao@Eddy-MBP2017.local
The key's randomart image is:
+---[RSA 2048]----+
|*O               |
|**+              |
|B%...   o        |
|&**. . + .       |
|E&+o  . S        |
|Xo+              |
|=+               |
|+o               |
|.o.              |
+----[SHA256]-----+
# 拷贝公钥到目标登录主机
>> cd ~/.ssh
>> ssh-copy-id -i id_rsa.pub hengkai@ls5.tacc.utexas.edu

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "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

Lonestar 5 is now enforcing Multi-Factor Authentication.  To access the system:

1) If not using ssh-keys, please enter your TACC password at the password prompt
2) At the TACC Token prompt, enter your 6-digit code followed by <return>.
Password: #输入密码
TACC Token Code: #输入二步验证码

Number of key(s) added:        1

Now try logging into the machine, with:   "ssh 'hengkai@ls5.tacc.utexas.edu'"
and check to make sure that only the key(s) you wanted were added.
# 从此ssh登录不再需要密码

参考:
https://www.jianshu.com/p/84b506ae2201
https://my.oschina.net/shipley/blog/1507337

Last modification:January 15th, 2020 at 07:49 pm
If you think my article is useful to you, please feel free to appreciate