Skip to content

Latest commit

 

History

History
116 lines (84 loc) · 1.88 KB

07-ssh.md

File metadata and controls

116 lines (84 loc) · 1.88 KB

Setup ssh

We will setup our ssh key to connect to Github.

Manage your ssh

Typically you would have one key pair for your machine but sometimes you need multiple
ie: personal, work internal and client.

Setup ssh config file

This files lets us setup diffent host to use our ssh key.

nano ~/.ssh/config
#~/.ssh/config

Host *
  AddKeysToAgent yes
  UseKeychain yes

# git clone [email protected]:[account]/[project].git
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

Add Identity to SSH

ssh-add ~/.ssh/id_rsa

Verify that the Identity was added

#List fingerprints of all identities.
ssh-add -l

#List public key parameters of all identities.
ssh-add -L

copy public key

Add the Public key to the server you want to connect to. ie: github.com

#Copy Public key to clipboard.
pbcopy < ~/.ssh/id_rsa.pub

test connection

ssh -T github.com

Other Stuff

Delete all identities

For when you need to remove your identities.

#Delete all identities.
ssh-add -D

Examples Host

Example Host for different situations.

#EXAMPLES
# ssh cwc-server
Host cwc-server
  HostName ssh.example.com
  Port 1111
  User cwc
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

# ssh cwc-client
Host cwc-client
  HostName client.example.com
  User cwc
  IdentityFile ~/.ssh/id_rsa_client
  IdentitiesOnly yes

# git clone git@gh-work:[account]/[project].git
Host gh-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_work
  IdentitiesOnly yes

Table of Content