-
I’ve Generated new SSH keys (private & public), stored the private SSH key as a secret and added the public one to In my github action I’ve writing the private key as a file.
Then using this file
It fails on Host key verification failed. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
That message means that the connection failed because your server could not be authenticated. You should write the host key (from /etc/ssh/ssh_host_KEYTYPE_key.pub) to the ~/.ssh/known_hosts file on the runner together with the host name, e.g.:
|
Beta Was this translation helpful? Give feedback.
-
Thank you! I’ve used this in order to add my server to known_hosts fille
And it solved the previous error, but, now I get this:
Any pointers? |
Beta Was this translation helpful? Give feedback.
-
That error probably means that your server doesn’t accept the configured private key for the target user. Check that the matching public key is included in the authorized_keys file of that user. Also, if you use the result of ssh-keyscan without verification you’re effectively disabling host key checking. Consider if that really is an acceptable risk according to your security model. |
Beta Was this translation helpful? Give feedback.
-
Ok, i will try to with your approach. |
Beta Was this translation helpful? Give feedback.
-
Ok, so I’ve changed my approach, I’ve entered to my server,
And I still get the same thing :\
|
Beta Was this translation helpful? Give feedback.
-
I solved it!!! Once I’ve generated a new ones without it, it worked. So that is the whole process:
In your workflow.yml file
Then you can use ssh with
|
Beta Was this translation helpful? Give feedback.
-
Could you please provide an example with rsync? thanks in advance |
Beta Was this translation helpful? Give feedback.
-
What are you trying to do with rsync? There shouldn’t be any difference, if SSH works you can use rsync over SSH without any additional steps. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
I solved it!!!
Apparently keys were protected with passphrase 🤯.
Once I’ve generated a new ones without it, it worked.
So that is the whole process:
Genereate new keys
ssh-keygen -t rsa -b 4096 -C “user@host” -q -N “”
Update your host’s
authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub user@host
Enter the server & run
ssh-keyscan host
Copy the output to github secret (let call it SSH_KNOWN_HOSTS)
Copy the private key to a github secret (lets call it SSH_PRIVATE_KEY)
In your workflow.yml file