Skip to content
Amanda on Mona edited this page Oct 28, 2018 · 1 revision

If you've got a handle on the command line locally (that is, on your own machine) but you're struggling to sort out how you'd execute commands on a server or, more precisely, on a computer you don't happen to have a keyboard connected to right this moment, the answer is ...

SSH

SSH, or Secure Shell,

If you're running Mac OSX or Linux, your machine has an SSH client built right in. Try it: type which ssh at the command line. Windows users will need to install puTTY.

To open a shell connection to another machine, you need to know that machine's name (which you already know if you're using SFTP to connect) and you need a username and password. Connect with:

ssh username@example.domain.com

It's actually that simple.

Keys for more Security

You're probably used to using passwords as your default authentication method, but you'll get much better security if you switch to SSH Keys. I used to have a really nice explanation of keys up on a blog I don't control, and it seems to be gone, which means I need to reconstruct it. Until I do that, here's a rough rundown:

  • Keys are much stronger than passwords because they're really long and random.
  • You can authorize lots of keys, which means you don't have to share passwords.
  • You know how it is really easy to multiply two big numbers by each other, but very difficult to factor a very large number? That's the cool math that SSH key pairs take advantage of.
  • You use a command line tool to generate a pair of keys, one private and one public.
  • Keep your private key private. Always.
  • Add your public key to a file on the server, called .ssh/authorized_keys (that means you're going to create a folder called .ssh and then a file in that folder called authorized_keys
  • You can put as many keys as you want in your authorized_keys file. So you can create key pairs on all the machines you use regularly, and put public keys from anyone else who should have access to your server. If you want my help with something, you can add my public key to authorized_keys and I can access your server. No password sharing required.

If you want help generating and using SSH keys, let me know!

Advanced SSH

You can actually do some super cool things with your own .ssh/config file. Nudge me if you're curious.

Feedback? Edits? You are welcome to edit this page, all you need is a Github account. And if you see a problem here that you're not personally inclined to fix, don't hesitate to file an issue