Configure SSH Keys
How to Set Up SSH Keys on Ubuntu
Access the VPS from your machine
Generate a new SSH key on your computer:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f ~/.ssh/id_rsa_myserver
Start the ssh-agent and copy the key to the server:
eval "$(ssh-agent -s)"
ssh-copy-id -i ~/.ssh/id_rsa_myserver sammy@your-server-ip
Test access with the new key:
ssh -i ~/.ssh/id_rsa_myserver sammy@your-server-ip
Access GitHub from the VPS
Generate a new SSH key on the server:
ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/id_ed25519_github
Create an SSH config file:
echo "
# GitHub.com
Host github.com
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519_github
" > ~/.ssh/config
Print the public key and add it to GitHub under Settings → SSH and GPG keys:
cat ~/.ssh/id_ed25519_github.pub
Test the connection:
ssh -T git@github.com