2016-01-13 82 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。 最後,安裝卷是成功的。