简体   繁体   English

无法通过ubuntu中的配置文件将ssh连接到ec2。 权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)

[英]Unable to connect ssh to ec2 through config file in ubuntu. Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

Unable to connect to SSH through Ubuntu. 无法通过Ubuntu连接到SSH。 But it works fine on MAC. 但它在MAC上工作正常。

My Config File 我的配置文件

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

Connecting through SSH 通过SSH连接

$ ssh testserver

This is same i did for Mac and for my Ubuntu. 这与我为Mac和Ubuntu所做的一样。 It works perfectly in Mac but in Ubuntu an error is thrown Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 它可以在Mac上完美运行,但是在Ubuntu中会引发错误, Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Now i tried the alternate way ssh -i '/home/kavin/.ssh/AnotherKey.pem' ec2-user@54.201.xxx.xxx 现在我尝试了另一种方式ssh -i '/home/kavin/.ssh/AnotherKey.pem' ec2-user@54.201.xxx.xxx

This works fine in both Mac and Ubuntu. 在Mac和Ubuntu上都可以正常工作。

Can you please tell me where i went wrong 你能告诉我我哪里出问题了吗

These are the logs of $ ssh testserver -v 这些是$ 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.

As you say, 正如你所说,

ssh -i '/home/kavin/.ssh/AnotherKey.pem' ec2-user@54.201.xxx.xxx

from ubuntu m/c works and ssh testserver fails. 来自ubuntu m / c的工作原理和ssh testserver失败。 I would suggest comment other lines from config file and just keep 我建议从配置文件中注释其他行,然后继续

IdentityFile /home/kavin/.ssh/AnotherKey.pem 

Make sure, you remove the quotes and the path should directly be available to key. 确保删除引号,并且路径应直接可用于键。

Goto Terminal: 转到终端:

  1. gksu nautilus (enter your root password) gksu nautilus(输入您的root密码)
  2. browse to /etc/ssh/ 浏览到/ etc / ssh /
  3. copy your 'key' in /etc/ssh/ 将您的“密钥”复制到/ etc / ssh /
  4. open ssh_config 打开ssh_config
  5. copy paste: 复制粘贴:

    Host testserver 主机测试服务器

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

    User ubuntu 用户ubuntu

    IdentityFile /etc/ssh/AnotherKey.pem IdentityFile /etc/ssh/AnotherKey.pem

  6. save - exit 保存-退出

  7. open new terminal 打开新终端

  8. sudo -i 须藤-i

  9. enter password 输入密码

  10. cd /etc/ssh cd / etc / ssh

  11. chmod 400 'your-key' chmod 400'您的钥匙'

  12. ssh testserver SSH测试服务器

-- make sure your 22 port is open -确保您的22端口是开放的

https://askubuntu.com/questions/410218/how-to-close-an-open-port-in-ubuntu-12-04 https://askubuntu.com/questions/410218/how-to-close-an-open-port-in-ubuntu-12-04

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EC2 ssh 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic) - EC2 ssh Permission denied (publickey,gssapi-keyex,gssapi-with-mic) Git权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)? - Git Permission denied (publickey,gssapi-keyex,gssapi-with-mic)? 无法使用 ansible ping RHEL 主机。 错误:“权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic、密码) - Cannot ping RHEL hosts using ansible. Error: 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) 尝试通过SSH进入Amazon EC2时出现“权限被拒绝(公钥)。” - “Permission denied (publickey).” while trying to SSH into Amazon EC2 Amazon EC2实例“权限被拒绝(公钥)” - Amazon EC2 instance “Permission denied (publickey)” Amazon ec2显示“权限被拒绝(公钥)” - Amazon ec2 show “Permission denied (publickey)” 从 ec2 到 github 的权限被拒绝(公钥) - Permission denied (publickey) from ec2 to github AWS_EC2 ssh 权限被拒绝(公钥) - AWS_EC2 ssh Permission denied (publickey) 无法通过 SSH 连接到远程 Amazon 实例(权限被拒绝(公钥)) - Not able to connect to remote Amazon Instance via SSH (Permission denied(publickey)) EC2密钥对在一个实例中起作用,但在另一个实例上失败-权限被拒绝(公钥) - EC2 keypair works in one instance but fails on other - Permission denied (publickey)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM