DEV Community

Discussion on: How to setup continuous deployment of a website on a VPS using GitHub Actions

Collapse
 
azrinsani profile image
Azrin Sani • Edited

Hi, I just created an account to answer this question. I was going through this problem as well. For me it turned out that I have not enabled SSH keys on my VPS

in a nutshell, make sure you have "AuthorizedKeysFile %h/.ssh/authorized_keys" in your '/etc/ssh/sshd_config' file entrt

HOW IT FULLY WORKS:

  • Every device/service(such as github), will generate a private and public key pair using SSH. In this example we are using the actual vps to generate the private-public key pair and manually copy the private key into Github.
  • The private key stays on the device/service, but the public key is copied into ~/.ssh/authorized_keys on your VPS
  • So when Github logs into you vps, it uses the private key to sign the handshake message. The VPS uses the public key to verify the signature and since it is 'Authorized' will allow login.
  • under /etc/ssh/sshd_config must uncomment 'AuthorizedKeysFile %h/.ssh/authorized_keys'
  • Finally don't forget to restart SSH => $ sudo service ssh restart
Collapse
 
rein96 profile image
Reinhart Andreas

Thanks for the help Bruce and Azrin!