Skip to main content

SSH Basic

Installing SSH Agent

Install openssh with homebrew

brew install openssh

Generating & Setting up

Mac

Open Terminal & paste this with your email

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Start ssh-agent if not running

eval "$(ssh-agent -s)"

Open to ssh config file (woks on macOS Sierra 10.12.2 or later)

open ~/.ssh/config

Update the config with this (add at bottom)

paste this if you want to use key for all server

Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

paste this if you want to use key for specific server


Host [example.com] //server-name here
HostName git.example.com //actual server address
User sshuser //username
IdentityFile ~/.ssh/id_rsa //file location
UseKeychain yes
AddKeysToAgent yes
ForwardAgent yes

Store passphrase to your keychain ( optional)

if you don't want to input passpharse everytime

ssh-add -K ~/.ssh/id_rsa

Copy public key to clipboard

pbcopy < ~/.ssh/id_rsa.pub