Skip to content

Instantly share code, notes, and snippets.

@KarmaBlackshaw
Last active June 2, 2024 17:27
Show Gist options
  • Save KarmaBlackshaw/5a948e0a74962c16916fbd2030c1aaa0 to your computer and use it in GitHub Desktop.
Save KarmaBlackshaw/5a948e0a74962c16916fbd2030c1aaa0 to your computer and use it in GitHub Desktop.
Generate SSH Key for Github

Generate SSH Key in your server

ssh-keygen -t ed25519 -C "[email]" -f ~/.ssh/[name]

Copy the key in the .pub file and paste it in your gh access tokens

$ cat ~/.ssh/id_ed25519.pub
# Then select and copy the contents of the id_ed25519.pub file
# displayed in the terminal to your clipboard

If your ssh is not being read and fails to perform any git operations due to permissions

# Check if your key is listed
ssh-add -l

# If not, add your key
ssh-add ~/.ssh/id_rsa

# If facing an error "Count not open a connection to your authentication agent."
eval `ssh-agent -s`

Add config file in ~/.ssh/config Here's a sample content

# KarmaBlackshaw
Host github-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/karmablackshaw

# OutliantJeash
Host github-outliant
  HostName github.com
  User git
  IdentityFile ~/.ssh/outliant

Remember, when cloning from a specific account, change the host address

# from
git@github.com:ByWinona/admin-dashboard-next.git

# to
git@github-outliant:ByWinona/admin-dashboard-next.git
@KarmaBlackshaw
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment