Generating SSH Keys

SSH, or secure shell, is a secure protocol and the most common way of safely administering remote servers. It’s important to understand how SSH is used for authentication with Git and similar tools.

I have multiple accounts in Github and Bitbucket for the usage of work and personal. So I had to set up multiple SSH keys on a single machine.

Generate a SSH key-pair

$ ssh-keygen -t rsa -C "public.hodoo@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/davidlee/.ssh/id_rsa): /Users/davidlee/.ssh/id_rsa_github
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/davidlee/.ssh/id_rsa_github.
Your public key has been saved in /Users/davidlee/.ssh/id_rsa_github.pub.

Adding a new SSH key

# Mac
$ pbcopy < ~/.ssh/id_rsa_github.pub

Set a config file

# ~/.ssh/config
Host hodoogithub
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_github

Let’s connect!

$ ssh -T git@hodoogithub
Hi hodoolee! You've successfully authenticated, but GitHub does not provide shell access.

Set a remote-url

$ git remote set-url origin git@hodoogithub:hoodoolee/project.git

Taeyang Lee

Taeyang Lee
I really enjoy taking on tasks which are out of my comfort zone and using them as a great way to learn the necessary tools to complete it.

Monads

Published on December 17, 2018

Functors

Published on December 16, 2018