Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 从Mac OSX到AWS VM的SSH-权限被拒绝(公钥)_Macos_Ssh_Amazon Ec2 - Fatal编程技术网

Macos 从Mac OSX到AWS VM的SSH-权限被拒绝(公钥)

Macos 从Mac OSX到AWS VM的SSH-权限被拒绝(公钥),macos,ssh,amazon-ec2,Macos,Ssh,Amazon Ec2,我将ssh密钥文件aws ssh key.pem.txt下载到我的Mac上,并使用 mv path/Downloads/aws-ssh-key.pem.txt ~./ssh/ 当我使用ls~/.ssh列出.ssh目录的内容时,我看到以下内容: aws-ssh-key.pem.txt id_rsa known_hosts config id_rsa.pub 现在,我从.ssh运行下面的命令 ssh -v -i aws-ssh-

我将ssh密钥文件
aws ssh key.pem.txt
下载到我的Mac上,并使用

mv path/Downloads/aws-ssh-key.pem.txt ~./ssh/
当我使用
ls~/.ssh
列出
.ssh
目录的内容时,我看到以下内容:

aws-ssh-key.pem.txt        id_rsa        known_hosts
config                     id_rsa.pub
现在,我从
.ssh
运行下面的命令

ssh -v -i aws-ssh-key.pem ubuntu@ec2-xx-xx-xx-xxx.us-west-2.compute.amazonaws.com
我得到以下错误:

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: PATH/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

有什么帮助吗?谢谢。

aws-ssh-key.pem.txt没有.txt扩展名

从AWS控制台下载的私钥必须具有.pem扩展名。 而且.pem文件仅对所有者具有读取权限。您可以通过sudo chmod 400 aws-ssh-key.pem分配该权限

注: 除非您想添加到ssh密钥对中,否则无需将.pem密钥移动到~/.ssh目录


您可以将.pem文件存储在任何安全目录中,并在ssh连接时提供该路径。

aws-ssh-key.pem.txt没有.txt扩展名。pem本身就是一个扩展。还要确保该文件仅具有仅来自所有者的读取权限。您可以通过sudo chmod 400 aws-ssh-key.pemYes当然可以,这样其他人就可以解决这种类型的问题。@Chintan7027是的,因为在aws文档中,它并不完全清楚。当我生成ssh密钥时,它会自动保存为.txt文件。我想知道那是什么。第(4)点对你很有用。