Git Lab - jude-lindale/Wiki GitHub Wiki
The lab manual is old, because GitHub already removed the authentication method that was showed in the lab's screenshots. They introduced to new methods for pushing and pulling stuff through the command line. The first one is through a personal access token and the second one is through a SSH key based authentication. You can generate a personal key from your account setting, but I decided to go with the SSH key authentication just because all I need to do is to put my SSH public key in GitHub. Follow the steps below to successfully use SSH deploy keys based authentication.
First generate a public key using the following command:
$ ssh-keygen -t ed25519 -C "[email protected]"
Copy the public key:
$ cat ~/.ssh/id_ed25519.pub
ex: ssh-ed25519 AAAAC3Nza..DWeRErgkAmabhQj2yj/onxlIQgli [email protected]
Go to repository setting and open the deploy keys tab and add a deploy key. Here is an example from my repo:
Use the git
command like this (for cloning, pushing, pulling, etc..):
$ git clone [email protected]:<username>/<repository>
$ git add .
$ git commit -m "<commit message>"
$ git push
$ git status
$ git pull
You can find below my script for configuring SSH keys, and password less login:
# secure-ssh.sh
# author Jude
# You have to run the script from where the script is located at
# Creating user
echo Create user name?
read USERNAME
sudo useradd -m -d /home/$USERNAME -s /bin/bash $USERNAME
sudo mkdir /home/$USERNAME/.sh
# copying SSH keys
touch /home/$USERNAME/.ssh/authorized_keys
cat ../public-keys/id_rsa.pub >> /home/$USERNAME/.ssh/authorized_keys
# Configuring access settings
chmod 700 /home/$USERNAME/.ssh
chmod 600 /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
chown -R $USERNAME:$USERNAME /home/$USERNAME
# Disable Root SSH
# Note this will work for both CentOS and Ubuntu
sed -i 's/#PermitRootLogin/PermitRootLogin/g' /etc/ssh/sshd_config
sed -i '/PermitRootLogin/s/yes/no/g' /etc/ssh/sshd_config
systemctl restart ssh