2016-01-13 86 views
0

将.ssh文件夹的所有者从用户更改为root后,我无法用ssh登录远程服务器。这里是错误信息:AWS无法使用SSH登录

OpenSSH_6.9p1, LibreSSL 2.1.7 
debug1: Reading configuration data /Users/qj/.ssh/config 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 20: Applying options for * 
debug1: Connecting to ec2-52-193-83-231.ap-northeast-1.compute.amazonaws.com [52.193.83.231] port 22. 
debug1: Connection established. 
debug1: key_load_public: No such file or directory 
debug1: identity file gmail.pem type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file gmail.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.9 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 
debug1: Authenticating to ec2-52-193-83-231.ap-northeast-1.compute.amazonaws.com:22 as 'ec2-user' 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client [email protected] <implicit> none 
debug1: kex: client->server [email protected] <implicit> none 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:EahONyMKzM6Q4tdEBSa9LwyOFI65KB02GesJGuGE9Ss 
debug1: Host 'ec2-52-193-83-231.ap-northeast-1.compute.amazonaws.com' is known and matches the ECDSA host key. 
debug1: Found key in /Users/qj/.ssh/known_hosts:25 
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: Offering RSA public key: /Users/qj/.ssh/dqj 
debug1: Authentications that can continue: publickey 
debug1: Trying private key: gmail.pem 
debug1: Authentications that can continue: publickey 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

这真的是我的错,更改.ssh文件夹的所有者。 任何人都可以帮我〜

+1

似乎你需要启动一个新的服务器,并使用附加的EBS卷(如果有需要的数据)。 –

+0

没有其他灵魂吗?例如从AWS管理器系统创建新用户。 – Qijin

回答

1

如果你真的需要保存服务器,你可以尝试从机器创建一个AMI。然后从那里重新启动。然后,AWS会尝试再次将您的公钥放入authorized_keys,并且很可能会修复权限问题。

如果没有,您可以随时启动新的服务器并将损坏的服务器EBS卷附加到新服务器以修复文件夹的权限。如果你有短暂的存储空间或者一个奇怪的文件系统,那就不要担心工作。

+0

我试图从机器创建AMI时保存服务器,而我也无法登录ami。这里是消息: **请以用户“ec2-user”而不是用户“root”的身份登录。 连接到ec2-52-192-184-132.ap-northeast-1.compute.amazonaws.com已关闭。** – Qijin

+0

...您是否尝试使用ec2-user作为用户名登录?然后你应该可以'sudo'来修改'/ root /'中的文件 – Paystey

0

我找到了答案,从https://forums.aws.amazon.com/thread.jspa?threadID=133054&tstart=0 下面是答案:

  1. 停止实例
  2. 拆离根卷
  3. 启动另一个实例(或者,如果你有一个已经可以跳过这一步)
  4. 将Volume 2连接到新的(或已存在的其他实例)
  5. 登录到实例
  6. 安装卷
  7. 更改文件夹权限酌情
  8. 卸除卷并将其分离
  9. 装回原来的instace
  10. 启动实例并连接

它发生一些在使用shell mount xvdf /ebs/ -t ext4(mkdir/ebs //此文件夹是挂载点,来自Making an Amazon EBS Volume Available for Use的更多详细信息)将卷挂载到新实例时,在步骤6中出现问题。错误消息是:

mount: wrong fs type, bad option, bad superblock on /dev/xvdf, 
     missing codepage or helper program, or other error 

     In some cases useful info is found in syslog - try 
     dmesg | tail or so. 

由于卷的文件系统是GPT。幸运的是,我从这篇文章中得到了原因Problem mounting GPT disk partition。而解决方案是,我需要安装/dev/xvdf1,而不仅仅是/dev/xvdf,如mount xvdf1 /ebs/ -t ext4。 最后,安装卷是成功的。