I'm trying to connect into AWS Ec2 server via mac Terminal but keep getting Connection closed by xx.xx.xx.xx
.
Here's what happened last night: I was in the server and was deleting and uploading files from git. Everything was working fine until it kicked me out while I was trying to sudo chmod -R 755
. Ever since I cannot get in from Terminal. Could this be a security issue, or could my key be damaged? Any help is appreciated.
Here are the steps that I took from terminal. Mykey.pem
is located on my desktop so..
cd desktop
sudo ssh -i "myKey.pem" ubuntu@xx.xx.xx.xx
I keep getting an error
Warning: Identity file myKey.pem not accessible: No such file or directory.
Connection closed by xx.xx.xx.xx
So I tried
chmod 400 mykey.pem
I keep getting an error
chmod: myKey.pem: No such file or directory
Has this happened to anyone? Is there a way to get in from terminal. By the way my instance is running normal and all my sites are up.
Best Answer
Don't use "sudo" to SSH. It might change your current working directory, and you don't need or even want to use root privileges to run a tool like that.
You're probably in the wrong folder. You don't say what OS you're running on, but on a Linux box, "desktop" and "Desktop" are not the same folder. On a Mac, they are. Check with "ls" to see that you can see the files you expect, other than that.