Every time you get a new machine and want to connect GitHub with SSH, it's so annoying to set up. Generate the SSH key after googling for a while and then manually copy & paste it to GitHub on their webpage.
Is it possible to do this whole process on the command line? Yes!
Today I'll introduce this brilliant CLI tool - gh-ssh-keygen.
How to use gh-ssh-keygen
There're two ways available.
Simply run this command if you don't want to install anything.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/maxam2017/gh-ssh-keygen/HEAD/gh-ssh-keygen.sh)"
Otherwise, you can install the whole command.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/maxam2017/gh-ssh-keygen/HEAD/install.sh)"
If this command has already been installed, it'll skip or upgrade if the new version is available.
Then, run
$ gh-ssh-keygen
After a few interactive steps, SSH key would be added to your GitHub account π
If you want to know more about how to use it, checkout this video for detail!
How this command works
Internally, it is powered by Official GitHub CLI which provides API to upload ssh keys.
$ gh ssh-key add [<key-file>] [flags]
Except that, I connect the whole process with the MacOS (and Linux) package manager brew
and OpenSSH auth utils ssh-keygen
together.
Also, this command handles lots of package installation things and implement some extra validation for user input. Therefore, feel free to use it if you need to add SSH key to your GitHub account next time!
Welcome to follow me or star β οΈmy repo if you're interested in it.
GitHub Repo: https://github.com/maxam2017/gh-ssh-keygen
GitHub Account: https://github.com/maxam2017
Top comments (0)