This guide will teach you how to use Github Deploy keys in your Hosting server here Im gonna use AWS lightsail Ubuntu 20
ssh-keygen -t rsa -b 4096 -C "[email protected]"
this will appear
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
just press ENTER or for advance user you can put a name on it and it will save to current directory you are on.
Enter passphrase (empty for no passphrase): (leave it blank if you dont want to input it everytime you do push/pull)
Enter (bypass) or put passphrase for more security
if you put passphrase it will ask you to do it again
Enter same passphrase again:
Your identification has been saved in <if_you_rename_the_key> or else it will save to /home/ubuntu/.ssh/id_rsa
Your public key has been saved in <if_you_rename_the_key>.pub or /home/ubuntu/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ciEKjS5LaC76asdqwesqweqweqwxcwerqweqwdasdas ubuntu@ip-<your-hosting-ip-address>
The key's randomart image is:
+---[RSA 3072]----+
|8====D . oo..+o. |
| o . . o.o.o.o|
| o ...... o . oo|
|.. . .+.o.. + . |
|oo.o.+.+So o o |
|+o+ E =o o . . |
|o. o . + . . |
|oo. + . |
|ooo 8======D . |
+----[SHA256]-----+
sudo nano ~/.ssh/config
Host gitreponame
Hostname github.com
IdentityFile "~/.ssh/id_rsa"
Note:
"Host" will be your <change_this_with_your_host_in_config_file> later on
"IdentityFile" will be your id_rsa (default) if you change it and changed its location you must indicate here
Note: to be sure change the file permission of id_rsa to 400
sudo chmod 400 ~/.ssh/id_rsa
Change the config file to 644
sudo chmod 644 ~/.ssh/config
type in:
cat ~/.ssh/id_rsa.pub
then copy the keygen and go to your repo (note: not in your account settings) and navigate to settings find Deploy Keys tab
eval `ssh-agent`
type in:
ssh-add
Enter passphrase (empty for no passphrase):
git remote -v
if its...
origin https://github.com/USERNAME/REPOSITORY.git
if its under your account
git remote set-url origin git@<change_this_with_your_host_in_config_file>:USERNAME/REPOSITORY.git
if its under an organization
git remote set-url origin git@<change_this_with_your_host_in_config_file>:ORGANIZATION/REPOSITORY.git