Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Blindacme's avatar

Failed to add the RSA host key for IP address [IP] to the list of known hosts . Permission denied (publickey).

Everything has been working fine for over a year when connecting via SSH and using automatic deploy. Now all of a sudden myself and my team get this error when trying to connect or deploy from GitHub. Using Digital Ocean Server + Forge.

Thu May 31 02:16:32 UTC 2018
Failed to add the RSA host key for IP address 'IPADDRESS' to the list of known hosts (/home/forge/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Anyone know how to solve? I have tried re-adding our keys to SSH section of forge, etc.

0 likes
9 replies
Nash's avatar

You also need to add the server's public key to GitHub. It can be found under Server details -> Meta (or SSH into your server and run cat ~/.ssh/id_rsa.pub)

1 like
click's avatar

so you are not able to get into the server? Or am I misreading this? I was wondering if you could figure out the current owner/permissions of the /home/forge/.ssh/known_hosts file.

1 like
Blindacme's avatar

The permissions of /home/forge/.ssh/known_hosts are 644, We are not able to deploy from Github OR SSH into the server all of a sudden

Nash's avatar

Can Forge access the server? If not, you may need to add Forge's public key (see Server details -> Meta) to your server. Forge's key need to be in both the /home/forge/.ssh/authorized_keys file and the /root/.ssh/authorized_keys file on your server. Your own public key needs to be added to the server as well, but you should be able to add that via Forge (if it has access).

If you can't SSH in from your own computer, you can get in via the console in the DigitalOcean control panel: https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-console-to-access-your-droplet#logging-in-with-the-console

Blindacme's avatar

I managed to get past that error by copying known_hosts file from root user to forge and I added forge user public key back to GitHub in the settings. Still keep getting this error

Load key "/home/forge/.ssh/id_rsa": Permission denied Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

permissions are set on /home/forge/.ssh/ to 755. don't even know what it is set to that but I made no changes. I created a new public and private key using sudo and still get the same error

Nash's avatar

You should not use sudo when generating the keys. Try again without sudo and copy the contents of the public key (/home/forge/.ssh/id_rsa.pub) to your GitHub settings.

Blindacme's avatar

I did use sudo to create my keys and added it to github and on github I can see the key is being used. Could it be permissions on those files? I have an option to create a new droplet on DigitalOcean. I'm using DO.

Blindacme's avatar

This is what makes me think it is a permission or something is wrong

debug1: Server host key: ssh-rsa SHA256:[omitted]
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/forge/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/forge/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
Load key "/home/forge/.ssh/id_rsa": Permission denied
debug1: Trying private key: /home/forge/.ssh/id_dsa
debug1: Trying private key: /home/forge/.ssh/id_ecdsa
debug1: Trying private key: /home/forge/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

Load key "/home/forge/.ssh/id_rsa": Permission denied -- line makes me think that something is wrong ?

Blindacme's avatar

Got it fixed by creating new keys without sudo command .. and adding them to authorized keys everywhere.. or I just got lucky .. All the answers in the thread were a lot of help. thanks

1 like

Please or to participate in this conversation.