打开终端 执行:

mkdir  ~/.ssh

第二步 将密钥对移到ssh目录下

mv ~/Downloads/MyKeyPair.pem ~/.ssh/MyKeyPair.pem

第三步 限制私有 SSH 密钥的权限

使用 chmod 命令来确保私有密钥文件不是公开可见的

chmod 400 ~/.ssh/mykeypair.pem

第四部 通过密钥连接远端服务器

格式如下:

ssh -i {您的 .pem 文件的完整路径} 用户名@{实例 IP 地址}

例如

ssh -i ~/.ssh/MyKeyPair.pem root@127.0.0.1

你会看到类似于这样的一段话:

The authenticity of host ‘127.0.0.1’ can’t be established. RSA key fingerprint is 1f:51:ae:28:df:63:e9:d8:cf:38:5d:87:2d:7b:b8:ca:9f:f5:b1:6f. Are you sure you want to continue connecting (yes/no)?

输入 yes 并回车,然后就可以看到已经连接上远程服务器了。

相关文章:

  • 2022-01-18
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2021-07-20
  • 2022-02-07
  • 2021-11-14
猜你喜欢
  • 2019-02-22
  • 2021-12-15
  • 2022-12-23
  • 2021-12-20
  • 2021-12-26
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案