Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.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
Linux 无法通过ubuntu中的配置文件将ssh连接到ec2。权限被拒绝(公钥、gssapi keyex、带麦克风的gssapi)_Linux_Macos_Ubuntu_Ssh_Amazon Ec2 - Fatal编程技术网

Linux 无法通过ubuntu中的配置文件将ssh连接到ec2。权限被拒绝(公钥、gssapi keyex、带麦克风的gssapi)

Linux 无法通过ubuntu中的配置文件将ssh连接到ec2。权限被拒绝(公钥、gssapi keyex、带麦克风的gssapi),linux,macos,ubuntu,ssh,amazon-ec2,Linux,Macos,Ubuntu,Ssh,Amazon Ec2,无法通过Ubuntu连接到SSH。但它在MAC上运行良好 我的配置文件 Host testserver User ubuntu IdentityFile '/home/kavin/.ssh/AnotherKey.pem' HostName ec2-54-201-xxx-xxx.us-west-2.compute.amazonaws.com 通过SSH连接 $ ssh testserver 这和我在Mac和Ubuntu上做的一样。它在Mac上运行得很好,但在Ubuntu中会抛出一个错误权限被

无法通过Ubuntu连接到SSH。但它在MAC上运行良好

我的配置文件

Host testserver
User ubuntu
IdentityFile '/home/kavin/.ssh/AnotherKey.pem' 
HostName ec2-54-201-xxx-xxx.us-west-2.compute.amazonaws.com
通过SSH连接

$ ssh testserver
这和我在Mac和Ubuntu上做的一样。它在Mac上运行得很好,但在Ubuntu中会抛出一个错误
权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic)。

现在我尝试了另一种方法
ssh-i'/home/kavin/.ssh/AnotherKey.pem'ec2-user@54.201.xxx.xxx

这在Mac和Ubuntu中都能正常工作

你能告诉我哪里出错了吗

以下是$ssh testserver-v的日志

OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /home/kavin/.ssh/config
debug1: /home/kavin/.ssh/config line 1: Applying options for testserver
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-54-200-26-1.us-west-2.compute.amazonaws.com [54.200.26.1] port 22.
debug1: Connection established.
debug1: identity file '/home/kavin/.ssh/AnotherKey.pem' type -1
debug1: identity file '/home/kavin/.ssh/AnotherKey.pem'-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1p1 Debian-4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 90:e1:d7:01:ab:cf:eb:2c:4b:8f:b2:5e:ad:05:a5:b8
debug1: Host 'ec2-54-200-26-1.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/kavin/.ssh/known_hosts:10
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: '/home/kavin/.ssh/AnotherKey.pem'
debug1: No more authentication methods to try.
正如你所说

ssh -i '/home/kavin/.ssh/AnotherKey.pem' ec2-user@54.201.xxx.xxx
从ubuntu开始,m/c工作并且
ssh testserver
失败。我建议对配置文件中的其他行进行注释,并保持

IdentityFile /home/kavin/.ssh/AnotherKey.pem 
请确保删除引号,并且路径应直接可用于键。

转到终端:

  • gksu鹦鹉螺(输入您的根密码)
  • 浏览到/etc/ssh/
  • 在/etc/ssh中复制您的“密钥”/
  • 打开ssh\u配置
  • 复制粘贴:

    主机测试服务器

    主机名ec2-54-201-xxx-xxx.us-west-2.compute.amazonaws.com

    用户ubuntu

    IdentityFile/etc/ssh/AnotherKey.pem

  • 保存-退出

  • 开放新码头

  • sudo-i

  • 输入密码

  • cd/etc/ssh

  • chmod 400“您的钥匙”

  • ssh测试服务器

  • --确保您的22端口已打开


    看起来您使用的钥匙不正确。您可以发布“ssh testserver-v”的输出吗?添加了-v的输出您必须确保AnotherKey.pem是您在创建密钥对时从AWS下载的密钥文件。删除此处的引号IdentityFile'/home/kavin/.ssh/AnotherKey.pem'