Use SSH! All the Cool Kids Are Doing It
Tags: beginners, webdev, github, git
Published: 2022-09-05 07:39:01

Hi! I'm BBurt! And today I'm gonna concisely walk you through setting up Secure Shell Access, of which, I only know a little. haha

So why, if I only know a little, am I trying to explain it? I'm glad you asked! 

Let me tell you :)

First of all, not too long ago, I was listening to the fabulous Syntax podcast (it's great, you prolly already know) episode [478](https://syntax.fm/show/478/supper-club-developer-experience-with-shawn-wang) with guest Shawn "Swyx" Wang and he mentioned his own [Learn In Public](https://www.learninpublic.org/), I was intrigued so I checked it out and read [this](https://www.learninpublic.org/v1-principles-learn-in-public.pdf) free chapter. It's good. You should read it.

But so, I'm taking his advice and learning in public!

The other reason I'm writing this is because, you know how they say that if your function is doing too much, or too many things, you should probably refactor, split it up into more than one function? 

Well similarly, I was writing this other piece here and it was doing too much. Hence this :) 

What the heck is SSH, anyways?

Well, how about a definition?

From [Wikipedia](https://en.wikipedia.org/wiki/Secure_Shell):
> The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.

Hey, that's us! Remote login and command-line execution.


From [GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh):
> Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit. You can also use an SSH key to sign commits.


I'm not sure what happened, normally I don't have to enter my username and password at the command line when fetching or pulling my own code from GitHub. But yesterday I had to do the whole personal-access-token-thing which led me down a rabbit hole, you know how that goes, and I ended up [here on StackOverflow](https://stackoverflow.com/questions/21095054/ssh-key-still-asking-for-password-and-passphrase/25721662#25721662).


On my machine, I have it set up to use SSH thanks to doing the course work at The Odin Project. Their instructions for setting up Git to use SSH to access GitHub can be found [here](https://www.theodinproject.com/lessons/foundations-setting-up-git#step-2-configure-git-and-github). By the way, I highly recommend their course (I'm still working my way through it).

I also highly recommend, if you're wanting to set up SSH, to follow the instructions on that link above, or [on GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh) for the official, longer guide, but for the sake of this article, I'm gonna tell you how. The short and sweet of it is as follows (I'm on Linux by the way):

 ```ls ~/.ssh/id_ed25519.pub``` 

to check if you have an ED25519 algorithm SSH key already installed.

If you get no output, or "No such file or directory" from running that command, you can generate a key by entering:

```ssh-keygen -t ed25519 -C <your-email>```

(I know y'all know better but, you'd put your own email address in there, minus the brackets) then just hit enter and enter again for the two questions after that.

Go to GitHub settings --> on the left-hand side click, "SSH and GPG keys" --> click "New SSH key" --> name it something wonderful, then leave that page as is for a sec, go back to your command line and run:

 ```cat ~/.ssh/id_ed25519.pub```
 
you'll get a long string that ends with your email address, copy that badboy into your clipboard, go back to GitHub and paste er on in there. Then click the "Add SSH key" button.

And that's it! No more having to enter your username and fussing with access tokens just to push or pull your code.

You can test it with: 

```ssh -T git@github.com```

and you'll get a nice little message from GitHub :)


![A command-line greeting from GitHub that says, "Hi beeburrt! You've successfully authenticated, but GitHub does not provide shell access."](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6zc6egh685yprlxmtiy.png)

I know that GitHub currently recommends HTTPS over SSH, but I still like using SSH.

I don't have much at stake, with regard to sending my data over the wire, but I can imagine there are others (journalists, activists, government devs?) that have a lot more on the line where security really IS of the utmost importance. In those cases, I can see how this decision, whether to use SSH or HTTPS, would take a lot of crucial consideration.


That's all. I hope you like my writing, maybe I'll keep it up :) haha Let me know in the comments which one you use, SSH or HTTPS and why.

[buy me a coffee!](https://www.buymeacoffee.com/beeburrt)