Logging into Git from a Remote Server

Git remote server setup can be tricky with the updated rules Github has, here we will dive into the basics of logging in while keeping your keys secure.

There are two ways to "login" to Git the first way to to fill out the two commands below:

1git config --global user.name "your_username"


1git config --global user.email "[email protected]"

This method however is outdated if you are trying to log in to a GitHub repository. To login to a GitHub repo will have to install the gh tools you can do that by pasting the following command into a terminal connected to the remote server.

1type -p curl >/dev/null || sudo apt install curl -y
2curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
3&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
4&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
5&& sudo apt update \
6&& sudo apt install gh -y

This comes from the installation guide here and works for Linux, if your remote server is not Linux you can follow the guide here.

After the gh tools finish installing you will need to run this:

1gh auth login

This will bring up a login wizard, if you are on a remote server it will try to open the link it gives you on the device. you will need to copy and paste this link onto your local machine and type the code that is also provided. Once you log in you are set up to use git as normal.