Accessing GitHub in the server using the deploy key
A deploy key is like a secret code that allows the computer to communicate with GitHub without using a username and password. Using the deploy key you can restrict the server to access only a single repository. The deploy key attaches to the public key in GitHub.
1. Connecting to the server
First, you have to connect to the server. Duh? you know? okay sure. Here is the command so you don’t have to search google.
ssh -i path-to-pem-file username@ipaddress
2. Generating SSH key
You can generate the key by using the following command. If you need more details, you can check this out.
ssh-keygen -t ed25519 -C "youremail@example.com"Now add your key to ssh-agent
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519
3. Adding SSH key as a deploy key
Go to your repo URL
Go to the settings of your repo.

Go to the Deploy Keys and click on
Add deploy key

Copy the content of .pub key file from the server that you generated in step 1.
cat ~/.ssh/id_ed25519.pub # copy the contentPaste the key on the text box on Github. Also, add a title.
Now check the connection to GitHub using
ssh -T git@github.com Hi github-username/repo-name! You've successfully authenticated, but GitHub does not provide shell access.you may be asked "Are you sure you want to continue connecting (yes/no/[fingerprint])" Just hit
yes
Ps. You can get more details here.
4. Cloning project from GitHub
git clone git@github.com:github-username/repo-name.git
Congratulation, you have cloned your and now have access to your single repo

