site/wiki/pages/ssh.md

299 lines
8.6 KiB
Markdown
Raw Permalink Normal View History

2018-06-04 06:18:28 +00:00
---
author: ~ben
published: true
title: ssh
2018-06-09 14:52:58 +00:00
description: ssh tutorial and background info
2019-02-04 15:35:39 +00:00
category:
2022-09-29 18:53:09 +00:00
- beginners
- technical
- guides
2018-06-04 06:18:28 +00:00
---
2019-02-04 15:35:39 +00:00
_or, how to tell other computers to do cool things_
2018-06-04 06:18:28 +00:00
2018-06-09 00:22:19 +00:00
---
> all users are required to use an ssh keypair for login, or will be required
2022-09-29 18:53:09 +00:00
> to proceed with manual account recovery with [~ben](/~ben/) or another admin.
> drop a line to [sudoers@tilde.team](mailto:sudoers@tilde.team) or hop on
[irc](https://tilde.chat/kiwi/#team) for assistance.
2018-06-09 00:22:19 +00:00
2018-10-26 18:24:13 +00:00
## tilde.team details
ports 22, 80, 443, and 2222 are available for ssh.
2019-02-04 15:35:39 +00:00
the primary ip has 80 and 443 in use by nginx.
2018-10-26 18:24:13 +00:00
use ssh.tilde.team to reach the secondary ip and use 80 and 443 for ssh.
so, for example, you can do:
2022-02-17 17:22:30 +00:00
ssh -p 443 user@ssh.tilde.team
ssh user@tilde.team # this uses port 22, which can be blocked on some networks
2018-10-26 18:24:13 +00:00
2022-02-17 17:22:30 +00:00
tilde.team's fingerprints are:
ECDSA: SHA256:R3qNfKIF3IiXhKCbFX6rCKl73yzexi9Wodsow6XFres
ED25519: SHA256:FErDF9upMkSg/yzw0N7i2o971LT/Bocd1qrDDpE315I
RSA: SHA256:JR5oQPfC34ogd/SeIcMpaGR8BiBo4ciI5xWyBVCjj5o
2020-01-01 20:57:54 +00:00
the key fingerprints are in dns as sshfp records as well, which you can check against
by setting VerifyHostKeyDNS to yes in your `~/.ssh/config`.
you can check the records yourself with the `dig` tool like this:
dig sshfp tilde.team
2018-10-26 18:24:13 +00:00
---
2019-02-04 15:35:39 +00:00
2018-10-26 18:24:13 +00:00
## intro
2018-06-09 00:22:19 +00:00
** if you just want to get right to a tutorial you can
[skip over this background info](#how-to-make-an-ssh-key)**
2018-06-09 00:22:19 +00:00
while [tilde.team](https://tilde.team) is accessible on the web and features
lovely web pages written by its users, most interaction with tilde.team takes
place **inside the machine** that runs tilde.team as opposed to via web forms
that have an effect from **outside** tilde.team's computer.
2018-06-09 00:22:19 +00:00
this is what sets tilde.team apart from most other online communities. you
connect directly to another computer from yours alongside other people and then
write your web pages, chat, and play games all via text-based interfaces right
on tilde.team's computer.
2018-06-09 00:22:19 +00:00
prior to the web (which debuted in 1995) this is how pretty much all computer
stuff got done. you connected directly to a machine (usually over a direct,
physical phone line) and did your work there.
2018-06-09 00:22:19 +00:00
for a long time, people used a tool called
[`telnet`](https://en.wikipedia.org/wiki/telnet) to connect to other computers.
these days we use a tool called **ssh**.
2018-06-09 00:22:19 +00:00
`ssh` is a text-based tool that provides a direct connection from your computer
to another. ssh is an acronym that stands for secure shell. the _shell_ part
refers to the fact that it's a text-based tool; we use the word shell to refer
to a text-based interface that you give commands to. the _secure_ part refers
to the fact that, when you're using ssh, no one can spy on your connection to
another computer (unlike the old `telnet` command).
2018-06-09 00:22:19 +00:00
**why bother with all of this?** passwords are really insecure and hard to manage.
using keys makes life easier for you, fair user (your account is less likely to
be hacked) and for me, your humble sysadmin (less administration than passwords).
2018-06-09 00:22:19 +00:00
---
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
## how to make an ssh key
SSH supports a handful of types of cryptographic keys. The most used are [RSA](
2022-09-29 18:53:09 +00:00
<https://en.wikipedia.org/wiki/RSA_(cryptosystem)>) and the more modern [Ed25519](
https://en.wikipedia.org/wiki/EdDSA#Ed25519).
RSA is the de-facto standard and is supported everywhere (just choose a big
enough key like 4096 bits to be secure). Ed25519 is designed to be faster and
smaller without sacrificing security, so is best suited for embedded devices
or machines with low resources. It's supported on tilde (and really on any
modern system) but you may find older systems which do not support it.
2018-10-23 14:53:56 +00:00
Below you'll find instructions to generate either type (or both if you want).
2018-06-09 00:22:19 +00:00
Keep in mind that these instructions leave your private keys unencrypted in
your local hard disk. So keep them private; never share them. A good solution
is to provide a password for them at creation time, but this implies entering
a password any time you used them (impractical) or use something like [ssh-agent](
2022-09-29 18:53:09 +00:00
https://man.openbsd.org/ssh-agent.1) (a bit more complex)
We don't have documentation for this [(yet)](https://tildegit.org/team/site/src/branch/master/wiki)
so either go with no password keys, or ask on IRC ([#team](https://web.tilde.chat/?join=team)) for help.
2022-01-15 21:52:46 +00:00
pick your fighter: [[mac](#mac)] | [[windows](#windows-10)] | [[linux](#linux)]
2018-06-09 00:22:19 +00:00
---
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
### mac
#### generating your keypair
1. open terminal (it's in `/Applications/Utilities`)
2019-02-04 15:35:39 +00:00
1. create your .ssh directory:
```bash
mkdir -m 700 ~/.ssh
```
2018-06-09 00:22:19 +00:00
2019-02-04 15:35:39 +00:00
1. create your keys:
```bash
ssh-keygen -t ed25519 -a 100
```
2018-06-09 00:22:19 +00:00
1. if you press enter to accept the defaults, your public and private key will
2022-09-29 18:53:09 +00:00
be located at `~/.ssh/id_ed25519.pub` and `~/.ssh/id_ed25519` respectively
2018-06-09 00:22:19 +00:00
1. `cat ~/.ssh/id_ed25519.pub`
2018-06-09 00:22:19 +00:00
1. copy the output of the last command and paste it in the sshkey field on the
2022-09-29 18:53:09 +00:00
signup form (or email it to [~sudoers](mailto:sudoers@tilde.team) if you already have an account)
2018-06-09 00:22:19 +00:00
#### using your keypair
once [~ben](https://tilde.team/~ben/) or another admin approves your signup, you can join the tilde.team
1. open terminal (it's in `/Applications/Utilities`)
2018-06-04 06:18:28 +00:00
2018-06-09 00:22:19 +00:00
1. `ssh` to tilde.team:
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
```bash
ssh username@tilde.team
```
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
where username is your username (~ben would use `ssh ben@tilde.team`)
2018-06-04 06:18:28 +00:00
2018-06-09 00:22:19 +00:00
1. profit???
2018-06-04 06:18:28 +00:00
2018-06-09 00:22:19 +00:00
---
2019-02-04 15:35:39 +00:00
### windows 10
2018-06-09 00:22:19 +00:00
2022-09-29 18:53:09 +00:00
windows 10 1809 or later has openssh built in, so you no longer need to install third-party tools. if openssh is not
enabled, please see microsoft's documentation
on [openssh in windows](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview).
2018-06-09 00:22:19 +00:00
#### generating your keypair
1. open your new shell
1. create your .ssh directory
```powershell
mkdir .ssh
```
1. create your keypair
```powershell
ssh-keygen -t ed25519 -a 100
```
1. if you press enter to accept the defaults, your public and private key will
2022-09-29 18:53:09 +00:00
be located at `%UserProfile%\.ssh\id_ed25519.pub` and `%UserProfile%\.ssh\id_ed25519`
respectively
1. `type %UserProfile%\.ssh\id_ed25519.pub`
1. copy the output of the last command and paste it in the sshkey field on the signup form
#### using your keypair
once [~ben](https://tilde.team/~ben/) or another admin approves your signup, you can join the tilde.team
1. open powershell (right click start button and select "windows powershell")
1. `ssh` to tilde.team:
```bash
ssh username@tilde.team
```
where username is your username (~ben would use `ssh ben@tilde.team`)
1. profit???
---
### legacy windows
2022-09-29 18:53:09 +00:00
older versions of windows unfortunately do not come with openssh, and you will need to install a third-party tool. you
may choose from any of the following options:
2019-02-04 15:35:39 +00:00
- [windows subsystem for linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
- [msys2](http://www.msys2.org/)
- [git bash](https://git-scm.com)
2018-06-09 00:22:19 +00:00
1. open your new shell
1. create your .ssh directory
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
```bash
mkdir .ssh
```
1. create your keypair
2018-06-09 00:22:19 +00:00
```bash
ssh-keygen -t ed25519 -a 100
2018-06-09 00:22:19 +00:00
```
1. if you press enter to accept the defaults, your public and private key will
2022-09-29 18:53:09 +00:00
be located at `~/.ssh/id_ed25519.pub` and `~/.ssh/id_ed25519` respectively
2018-06-04 06:18:28 +00:00
1. `cat ~/.ssh/id_ed25519.pub`
2018-06-04 06:18:28 +00:00
1. copy the output of the last command and paste it in the sshkey field on the signup form
2018-06-04 06:18:28 +00:00
2018-06-09 00:22:19 +00:00
#### using your keypair
once [~ben](https://tilde.team/~ben/) or another admin approves your signup, you can join the tilde.team
1. open terminal (location will vary depending on your choice)
2018-06-09 00:22:19 +00:00
1. `ssh` to tilde.team:
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
```bash
ssh username@tilde.team
```
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
where username is your username (~ben would use `ssh ben@tilde.team`)
1. profit???
---
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
### linux
2018-06-04 06:18:28 +00:00
there are a lot of linux distros, but `ssh` and `ssh-keygen` should be available
in almost all cases. if they're not, look up how to install ssh for your distro.
2018-06-09 00:22:19 +00:00
#### generating your keypair
1. make sure you have a `~/.ssh` directory
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
```bash
mkdir -m 700 ~/.ssh
```
1. create your keys
2018-06-09 00:22:19 +00:00
```bash
ssh-keygen -t ed25519 -a 100
2018-06-09 00:22:19 +00:00
```
1. if you press enter to accept the defaults, your public and private key will
2022-09-29 18:53:09 +00:00
be located at `~/.ssh/id_ed25519.pub` and `~/.ssh/id_ed25519` respectively
2018-06-09 00:22:19 +00:00
1. `cat ~/.ssh/id_ed25519.pub`
2018-06-09 00:22:19 +00:00
1. copy the output of the last command and paste it in the sshkey field on the signup form
2018-06-09 00:22:19 +00:00
#### using your keypair
once [~ben](https://tilde.team/~ben/) or another admin approves your signup, you can join the tilde.team
1. open a terminal (this depends on your distro)
1. `ssh` to tilde.team:
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
```bash
ssh username@tilde.team
```
2019-02-04 15:35:39 +00:00
2018-06-09 00:22:19 +00:00
where username is your username (~ben would use `ssh ben@tilde.team`)
1. profit???
---
2018-06-04 06:18:28 +00:00
2022-09-29 18:53:09 +00:00
this tutorial is based on and uses parts
of [the tilde.club ssh primer](https://github.com/tildeclub/tilde.club/blob/master/docs/ssh.md)
and [the tilde.town ssh guide](https://tilde.town/wiki/getting-started/ssh.html).