Can't ssh to AWS EC2: Identity file not accessible

前端 未结 14 871
予麋鹿
予麋鹿 2021-02-02 06:08

I\'m unable to ssh to my EC2 server and am getting the error:

ssh -i /Users/Skeniver/Keepass/skeniver.pem ubuntu@xx.xxx.xx.xxx

Identity file /Users/Skeniver/Kee         


        
相关标签:
14条回答
  • 2021-02-02 06:20

    I had similar issue and found that there was hidden char in command, pasting to plain text editor and copy back helped me.

    0 讨论(0)
  • 2021-02-02 06:22

    This is weird, but in my case I was copying the command from a slack message and that repeatedly caused this error, even though I met all the above requirements. Typing the whole command without copying anything from clipboard worked for me. Posting this here and I hope this helps someone one day.

    0 讨论(0)
  • 2021-02-02 06:23

    I was having this same issue. Storing the identity file in my ~/.ssh directory and running cd ~/.ssh before ssh -i (identity_file) username@hostname worked. I only ran into the issue when trying to run the ssh command from outside the ~/.ssh directory. Hopefully that helps

    0 讨论(0)
  • 2021-02-02 06:24

    I got here while solving same or similar problem. After trying a few things this works for me eventually. I am on MacBook Pro and trying to connect to Ec2 Amazon Linux 2 using VSCode Remote SSH.

    I have to update this file

    /Users/MrRobot/.ssh/config

    There is a config in the file like below.

    IdentityFile xx.pem

    I have to update this to full path wherever your id_rsa or pem file is.

    IdentityFile /Users/MrRobot/.ssh/xx.pem

    0 讨论(0)
  • 2021-02-02 06:26

    There are multiple reasons to occurring this error. 1 you are trying to access from whatever path which is not match 2 either you do not have permission to do access 3 if you do not have access to that particular file you can try to change the mode of permission

    like the above solution

    sudo chmod 400 /Users/Skeniver/Keepass/skeniver.pem
    

    even if not then you can co-ordinate with the network or your cloud team whoever manage your cloud server

    0 讨论(0)
  • 2021-02-02 06:27

    You need the identity file to login to the box. Use the command:

    ssh -i (identity_file) username@hostname"
    

    This worked for me. Write just the filename (without any slashes), unlike Amazon EC2 tutorial which asks you to enter:

    ssh -i /path/key_pair.pem ec2-user@public_dns_name
    

    It worked for me after putting the identity file in the .ssh (hidden) folder on home. To view hidden folders on home, use ctrl+h

    0 讨论(0)
提交回复
热议问题