Member-only story

(Quick-note) SSH Keys Permissions

You want to add a SSH Key to your SSH Agent and you get an error `Permissions are too open.`

Diego Carrasco G.
1 min readFeb 23, 2023

You intend to add an SSH Key to your SSH Agent and you get an error Permissions are too open.

❯ ssh-add ~/.ssh/id_rsa  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/daco/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

Solution

If your keys need to be only readable by you:

chmod 400 ~/.ssh/id_rsa

If your keys need to be read-writable by you:

chmod 600 ~/.ssh/id_rsa

After that, you can add your key

ssh-add ~/.ssh/id_rsa

Could not open connection to your authentication agent

If you get this error

❯ ssh-add ~/.ssh/id_rsa 
Could not open a connection to your authentication agent.

Just eval your agent

eval `ssh-agent`

and then proceed to add your keys.

Reference

--

--

Diego Carrasco G.
Diego Carrasco G.

Written by Diego Carrasco G.

Hi, I'm an entrepreneur-turned-developer living in Germany. I enjoy learning, write, coffee and solving problems. I write mainly about technology.

No responses yet