Type the following command, using your email address in place of mine:
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/jesse/.ssh/id_rsa):
Created directory '/c/Users/jesse/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/jesse/.ssh/id_rsa.
Your public key has been saved in /c/Users/jesse/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:AtDI+/yPNxi8y6WzdTecvd6U/ir6Q8pBtg0dv/ZhHlY [email protected]
The key's randomart image is:
+---[RSA 4096]----+
| ..o |
| o.. . |
| .. . o |
| . . + . . E|
| o .. So + ..|
| o o. o.ooo=.|
| . +o..+=.=o+|
| .==o.o.o..=.|
| **...o.++o+|
+----[SHA256]-----+
$ ~/Documents/Code
This will generate a key pair that you can add to your ssh-agent. You can also use GitHub Desktop if you'd prefer to avoid SSH keys, but we would recommend that you use native CLI tools.
Ensure that the agent is running with the following command:
$ eval $(ssh-agent -s)
Agent pid 11684
You can then add your key to the agent as follows:
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/jesse/.ssh/id_rsa (/c/Users/jesse/.ssh/id_rsa)
Next up, we'll add your public key to your GitHub account so we can get going with the rest of the chapter. Navigate to https://github.com, click on your profile, and bring up your Settings page:
Then, we'll click on SSH and GPG keys and add in the key that you created on your machine:
Click New SSH key and then add your generated id_rsa.pub key. Importantly, do not add your id_rsa key, as that's private and should be kept safe and offline!
You can copy your public SSH key to your clipboard with the following command in Windows:
$ clip < ~/.ssh/id_rsa.pub
You can test it out once you've configured it with this command:
$ ssh -vT [email protected]
OpenSSH_7.7p1, OpenSSL 1.0.2o 27 Mar 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
….SNIP...
Hi anonymuse! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3328, received 2048 bytes, in 0.1 seconds
Bytes per second: sent 36660.1, received 22560.1
debug1: Exit status 1
If you see a message welcoming you by your username, you're all set!