-1

I have EC2 instance running in AWS. I can access it using SSH client and private key at work. Now, I want to connect to same instance from home using Ubuntu 18.04 OS. So I copied the private key and tried using SSH commands from ubuntu terminal. But I didn't work and AWS was saying that access is denied. I am not good with networking and security stuff. Can anyone help me on how I can access my AWS EC2 instance from ubuntu at home?

meticulous_guy
  • 133
  • 1
  • 1
  • 10
  • By 'copied the private key', you mean you've created a `~/.ssh` directory on your home system, and copied the private key file such as `id_rsa` into it? Have you checked the permissions of both the directory (should be 0x700) and private key file (0x600)? Also, try 'ssh -v' or '-vv' for more debugging information. – idoimaging Oct 29 '19 at 20:14
  • By "copied the private key", I mean that I got private key into pen-drive from my work laptop and paste it into my home laptop. I typed SSH in my Ubuntu terminal at home and got the SSH help details, so I believe I have SSH installed in my ubuntu. Now on my Ubuntu terminal, I am going to the directory where I have pasted my private key, and trying to access my AWS EC2 instance by SSH command. – meticulous_guy Oct 30 '19 at 06:01
  • Please have a look at the warning message in the question: https://stackoverflow.com/questions/201893/warning-unprotected-private-key-file-when-trying-to-ssh-into-amazon-ec2-instan This is the message I get but my scenario is completely different. My requirement is: Just want to use same EC2 instance from work and home laptop. Work laptop is windows 10. Home laptop is Ubuntu 18.04. – meticulous_guy Oct 30 '19 at 06:10

1 Answers1

-1

I managed to get it working finally. I went to the directory location where the key file is stored on Ubuntu terminal and then typed chmod 400 <yourPrivateKey.pem> and hit enter. Nothing happened. Then type SSH command to connect to my AWS EC2 instance. That's it, I got connected. Now, I really don't know what has happened there and how secure it is to connect this way. Any help is much appreciated. Thanks.

meticulous_guy
  • 133
  • 1
  • 1
  • 10
  • `chmod 400 mykey.pem` makes the key file private by making the permission mode of the pem file to read-only for you, and no access for any other user. This means no-one else can access the key, and SSH will fail with the warning until the key file is private. – idoimaging Oct 30 '19 at 13:47