Lets say I am given the ssh below.
ssh -i keypair.pem [email protected]
I want to save it in /Users/UserName/Documents/ServerKeys
I believe I would add this to the ssh key
ssh -i ~/Documents/ServerKeys/keypair.pem [email protected]
When I run this in the terminal I get
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/UserName/Documents/ServerKeys/keypair.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /Users/UserName/Documents/ServerKeys/keypair.pem
Permission denied (publickey).
Do I need to run chmod 400 keypair.pem at some point?
What I am I doing wrong and what else do I need to do to get into a server using the keypair?
Yes, you should make sure the permissions on the file are secure. With a mode of 0644, anyone else on the system could read the key and use it to connect to the remote system. Setting it to 0600 ensure you and only you can read and write to the file (apart from
root
).