Skip to content

Instantly share code, notes, and snippets.

@dennis-gonzales
Last active March 5, 2025 00:19
Show Gist options
  • Save dennis-gonzales/87b367d158ff17ac65d9ac018ed8e0da to your computer and use it in GitHub Desktop.
Save dennis-gonzales/87b367d158ff17ac65d9ac018ed8e0da to your computer and use it in GitHub Desktop.
SSH configuration and cheat-sheet

Setting up SSH key

Generate SSH key

 ssh-keygen -t ed25519 -C [email protected]  #ed25519 encryption
 ssh-keygen -t rsa -b 4096 -C [email protected] # rsa encryption

Generate SSH key with custom name

 ssh-keygen -t ed25519 -f ~/.ssh/personal_ed25519 -C [email protected] #ed25519 encryption
 ssh-keygen -t rsa -b 4096 -f ~/.ssh/personal_rsa -C [email protected] # rsa encryption

Start SSH agent

eval $(ssh-agent -s)

Add SSH identity

ssh-add ~/.ssh/id_ed25519

Copy the public key (to be added in your Git provider e.g. Github)

cat ~/.ssh/id_ed25519.pub

Test connection

ssh -T [email protected] # default
ssh -T git@work # org name

List all keys added to ssh-agent

ssh-add -l # list by fingerprint
ssh-add -L # full key in OpenSSH format

Similar guide 1 Similar guide 2

Setting up SSH with Git

Example config file for managing SSH profiles

// ~/.ssh/config

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519
Host xld
    HostName github.com
    User git
    IdentityFile ~/.ssh/xld_ed25519
Host z1
    HostName github.com
    User git
    IdentityFile ~/.ssh/z1_ed25519

Custom git user on different project folder

// ~/workstation/google/.gitconfig

[user]
	email = [email protected]
	name = dnnsgnzls

// ~/.gitconfig

[includeIf "gitdir:~/google/"]
    path = ~/workstation/google/.gitconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment