Configuring a github access token
STEP 1: Install xclip for copying the token to clipboard( you can skip this if you know how to copy it manually)- sudo apt update
- sudo apt install xclip
STEP 2: Generate an ssh key, in your terminal type
ssh-keygen
accept defaults as the token is being generated, finally you will be given the location of the private key and public key(ends with .pub) generated.
STEP 3: copy the public key to clipboard
xclip -selection clipboard < /home/your-user/.ssh/id_rsa.pub
STEP 4: Go to github.com->settings-> SSH and GPG
then generate new ssh key and paste your copied key.
STEP 5: (OPTIONAL) write a custom script to simplify cloning using your key.
in the terminal type:
touch clone;
inside this file put the following NB clone can be any name
#!/bin/sh
git clone $1 --config core.sshCommand="ssh -i ~/.ssh/id_rsa"
also in the above text replace id_rsa(private key) with the one you generated(the name you saw when you generated the key)
save the script and then give it permision
sudo chmod 777 clone
Then move this script to your binaries
sudo mv clone /usr/bin/
Test your script by visiting any of your secured githubrepo
on right hand side click the green button named code
you will see 3 options [HTTPS, SSH, Github CI]
choose ssh and copy the link
cloning the repo type
clone git@github.com:charity1475/pager.git
Comments
Post a Comment