A tutorial for new lab members on how to set up SSH access to github on sivri without messing up any other lab members SSH connections.
- Open a terminal and SSH into sivri
ssh remote@sivri
- Type
cd ~/.ssh
to navigate to the SSH directory - Generate an SSH key (use your email):
ssh-keygen -t rsa -C "<[email protected]>"
- The key generator will ask you for a filename.
- Make your filename
id_rsa_<github_username>
(e.g.id_rsa_johnsmith
)
- Make your filename
- Enter a passphrase (you will need to enter this passphrase every time you use the key). You can leave it blank if you want, but then anyone on sivri has access to your GitHub account.
- In your terminal, type
cat id_rsa_<github_username>.pub
to print the public key to the terminal. - Copy the public key to your clipboard (highlight the text and press
ctrl + c
) - Go to your GitHub account settings
- Click on the
SSH and GPG keys
tab - Click on
New SSH key
- Give your key a title (e.g.
PCCL Sivri
) - Paste your public key into the
Key
box - Click
Add SSH key
- Click on the
- Go back to your terminal and type
nano config
to open the config file in an editor - Append the following lines to the bottom of the config file:
# <Your Name>'s github ssh key Host github.com-<github_username> HostName github.com User git IdentityFile ~/.ssh/id_rsa_<github_username>
- Save the file and exit the editor
- Test your connection by typing
ssh -T github.com-<github_username>
. You should see a message likeHi <github_username>! You've successfully authenticated, but GitHub does not provide shell access.
- Now, for every repository you own, you should update the remote url:
git remote set-url origin [email protected]<github_username>:<path_to_your_repo>.git
- For example, if I wanted to update the remote url for the
set-up-ssh-tutorial
repository, I would type:git remote set-url origin [email protected]:BYU-PCCL/set-up-ssh-tutorial.git