mac 登录亚马逊云服务器报错:Permission denied (publickey).

申请的亚马逊云服务器EC2,实例为ubuntu系统

一、打开终端,定位到放置密钥的文件夹;

二、确保私有秘钥不是公开可见的:

chmod 400 密钥文件名.pem

三、两种方式连接云服务器:(假设实例的对公IP为:11.22.33.44)

ssh -i 密钥文件名.pem ec2-user@11.22.33.44

ssh -i 密钥文件名.pem ec2-user@ec2-11-22-33-44.us-east-2.compute.amazonaws.com

两种方式均报错:

Permission denied (publickey).

四、解决方法:

在亚马逊官方文档中有下面一段:

Get the default user name for the AMI that you used to launch your instance

  • For an Amazon Linux AMI, the user name is ec2-user.

  • For a Centos AMI, the user name is centos.

  • For a Debian AMI, the user name is admin or root.

  • For a Fedora AMI, the user name is ec2-user or fedora.

  • For a RHEL AMI, the user name is ec2-user or root.

  • For a SUSE AMI, the user name is ec2-user or root.

  • For an Ubuntu AMI, the user name is ubuntu or root.

  • Otherwise, if ec2-user and root don't work, check with the AMI provider.

最后一条说明存在使用ec2-user和root不能连接的情况,所以需要多尝试一下,由于我装的是ubuntu系统,直接将连接命令中的ec2-user换成ubuntu,完美连接。

问道,问道,道法自然,编程亦然。 作者:问道编程 浏览本文,如有些许收获,请点击推荐。 本站使用「署名 4.0 国际」创作共享协议,码字不易,如需转载或引用,需在文章明显位置注明作者及本文链接。
原文地址:https://www.cnblogs.com/wendaobiancheng/p/9042425.html