2017-11-10 240 views
2

在AWS上安裝SSL證書時,我重命名舊的crt文件(如傻瓜),現在我不再能夠通過SSH訪問AWS實例修復文件名稱。在移動SSL crt文件後不再能夠通過SSH訪問AWS

有沒有方法可以訪問我的AWS實例的SSH以外的文件?或者,有沒有辦法在SSL證書關閉時繼續使用SSH訪問實例?

最初當我的文件名稱的變更後的連接,我從服務器此提示響應時,SSH:

> ssh -vv -i tc.pem [email protected] 
OpenSSH_7.5p1, OpenSSL 1.0.2l 25 May 2017 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug2: resolving "tc.com" port 22 
debug2: ssh_connect_direct: needpriv 0 
debug1: Connecting to tc.com [1.1.1.1] port 22. 
debug1: Connection established. 
debug1: key_load_public: No such file or directory 
debug1: identity file tc.pem type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file tc.pem-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.5 
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000 
debug2: fd 3 setting O_NONBLOCK 
debug1: Authenticating to tc.com:22 as 'ubuntu' 
debug1: SSH2_MSG_KEXINIT sent 
Connection closed by 1.1.1.1 port 22 

在一個點上我做的服務器上重新啓動,現在,我得到這個當我嘗試SSH方式:

> ssh -i tc.pem [email protected] 
ssh: connect to host tc.com port 22: Connection timed out 

如果我能進入的服務器或訪問以任何方式重命名這些文件,這將是一個容易解決。感謝任何人可以提供的幫助。

回答

1

這很容易做到。基本上,您將在另一個Instancce上掛載EC2實例的根卷(EBS卷),編輯.ssh/authorized_keys,然後將該卷重新掛接到您的實例。

這裏是覆蓋這一步一步的文章:

SSH Key Access Recovery on EC2 Instances

有一些互聯網上的類似文章。

+0

完美的工作。我正在關注[這個其他頁面](https://aws.amazon.com/articles/how-to-recover-an-unreachable-linux-instance/),它和那個頁面的信息幾乎相同你提供。我確實有不同的掛載它,因爲它是一個ext4,但這也包括[這裏](https://stackoverflow.com/questions/28792272/attaching-and-mounting-existing-ebs-volume-to-ec2 -instance-文件系統的問題)。謝謝你的幫助,約翰! – Rob