I mistakenly have source .bash_profile
in the bashrc
file and vice versa. Now when I tried to ssh into the machine (ec2), it will stuck at loading bash and get connection closed in a second. Is there a way I could fix it? Could I mount the disk to another ec2 instance to fix the bash files?
I tried the following solution from the other post but it doesn't work:
% ssh -i "my-pem.pem" -t ubuntu@<server_address>.amazonaws.com "/bin/bash --noprofile --norc"
Connection to <server_address>.amazonaws.com closed.
Nothing else showed up. Do you have any idea on what was going wrong?
For sanity check, if I do ssh -i "my-pem.pem"ubuntu@<server_address>.amazonaws.com
, the message will be
...
28 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
New release '20.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Mon Feb 22 23:17:41 2021 from ip
Connection to <server_address>.amazonaws.com closed.
Update:
SFTP using FileZilla didn't work. Log:
Status: Connecting to <server_address>.amazonaws.com...
Status: Using username "ubuntu".
Status: Connected to <server_address>.amazonaws.com
Error: FATAL ERROR: Received unexpected end-of-file from SFTP server
Error: Could not connect to server
Status: Waiting to retry...
Status: Connecting to <server_address>.compute-1.amazonaws.com...
Response: fzSftp started, protocol_version=10
Command: keyfile "my-perm.pem"
Command: open "ubuntu@<server_address>.amazonaws.com" 22
Command: Trust new Hostkey: Once
Status: Using username "ubuntu".
Status: Connected to <server_address>.amazonaws.com
Error: FATAL ERROR: Received unexpected end-of-file from SFTP server
Error: Could not connect to server