Secure SHell (or SSH
), is a protocol for
remote accessing a computer via a secure, encrypted connection. If
you're on windows, you may need to download an SSH client, such as PuTTY, or you can access the
ssh
command through WSL.
On MacOS/Linux, the ssh
command should already be
available in your terminal.
To login, you'll need to SSH to the host
moontowercomputer.club
. However
moontowercomputer.club
has disabled password based access,
so you'll need to send us your public key to use key based
authentication.
SSH
uses the
public key to encrypt your connection/data, and this encrypted
information can only be decrypted by your private key - you use
your "key" (private key) to open the "lock" (public key).
On windows you may need to follow these steps. I'm not a windows user so I haven't tried it personally. Please let me know if they do/don't work and I'll update this guide accordingly (and help you get things set up if it didn't work).
On MacOS/Linux, it's very straightforward:
# Generate the key
ssh-keygen -t rsa
# Accept all the default in the command above, or customize them. The prompt is
# relatively straightforward, the only thing you might care about it is
# protecting the files with a password.
# Next, display the contents of the public key. You'll want to send me the
# output of this command so that I can grant you access to server.
cat ~/.ssh/id_rsa.pub
Just paste additional public keys in
~/.ssh/authorized_keys
, one public key per line! While you
can copy around your public/private key to every machine you'd
like to log in from, this is a bad idea because it's a security
risk. Just generate a new key pair for each machine.
Anything is daunting when you do it for the first time, but this is just like riding a bike! Eventually, it'll feel super natural, but at first you will struggle as you learn. Here's a good guide to get you started: https://www.freecodecamp.org/news/linux-command-line-bash-tutorial/.
Please, please, please ask questions on our group chat. We've got a lot of people who love to share their interests and bring new people into our community. We strive to be an inclusive, accessible, and beginner friendly space, and if we don't uphold those standards, or could serve your learning journey better, please let us know so we can learn and grow together.
Here's some things to google as you learn about SSH
!
ssh-copy-id
- copies public keys to an SSH server (not
super useful for us, because it requires password authentication
initially, but good to know about)scp
- copy a file from your local computer to a remote
server via ssh
mosh
- a newer utility that beefs up what
ssh
can do. We haven't enabled this on
moontower
yet though.ssh-fs
~/.ssh/config
- your SSH configuration file. You can
set custom aliases for SSH hosts among other things.So you'd like to host some content on the internet. You've come to the right place! As a member of Moontower Computer Club, you have the awesome power of making content available on the world wide web :D
Anything you put in ~/public
will be publically
visible at
https://moontowercomputer.club/~<YOUR USERNAME>/
. For
example, if you had a picture called selfie.jpg
and it was
present at ~/public/images/selfie.jpg
, you could also view
the picture in your browser at:
https://moontowercomputer.club/~<YOUR USERNAME>/images/selfie.jpg
.
There are a few exceptions:
.
) will never be served.public/cgi-bin/
is special. More on this
below.Additionally, the filename index.html
is special and can
be omitted in the URL. For example, if you go to to
https://moontowercomputer.club/~foo/
, the file in
/home/foo/public/index.html
will be served. If you go to
https://moontowercomputer.club/~foo/bar
,
/home/foo/public/bar/index.html
will be served, assuming
that /home/foo/public/bar
doesn't already exist as a
file.
~
(tilda)s?
~
is shorthand for
/home/<YOUR USERNAME>
. Your shell should
automatically translate ~
to
/home/<YOUR USERNAME>
when it sees it. On the website
we use /~<YOUR USERNAME>
as part of the URL mostly by
convention.
First things first, you'll need to have set up your ssh access. Next you'll need some kind of editor. You have two options here:
For editing on the server itself, I recommend learning how to use
vim
(or neovim
), or at least becoming aware of
nano
. Both vim
and nano
are
preinstalled on moontower
.
For editing locally, check out vscode
's ssh
plugins. These let you run a full graphical editor (vscode
)
locally, but it also enables remotely accessing files on the server.
Another option to use a graphical editor in this way is to use
git
to synchronize changes across machines, and another
other option is to use scp
or rsync
for a
similar affect.
You'll have to learn HTML/CSS/JS
on your own* (*: we'll
help you out, but you need to poke around a little to find out what you
need help with), but here's a quick little starter pack:
<!DOCTYPE html>
<html>
<head>
<title>My Homepage</title>
</head>
<body>
<h1>Hello world!</h1>
<p>This is my homepage!!!</p>
</body>
</html>
Put this in ~/public/index.html
and see it live at
https://.../~<YOUR USERNAME>/
!
No. You could also just do plain text, or you can also omit a lot of stuff and it would still render mostly fine. For example, you could totally just do:
<h1>Hello world!</h1>
This is my homepage!!!
And it would mostly look the same (sans the custom window title).
Any executable file in ~/public/cgi-bin
will be run when
the corresponding URL is accessed. The executable must output any HTTP
headers you wish to set, followed by two new lines, then any content
you'd like (can be binary). For example suppose we save the following in
/home/aneesh/cgi-bin/test.sh
:
#!/usr/bin/bash
echo "Status: 200 OK"
echo "Content-Type: text/plain"
echo
echo
echo "Hello world!"
I can mark this file as executable by running
chmod +x ~/test.sh
, and now if I go to
https://moontowercomputer.club/~aneesh/cgi-bin/test.sh
, it
will run the above script and I should see a webpage that displays
Hello world!
and nothing else. You can do some cool things
with this - the script can implement any logic you'd like, and can be
written using any programming language you want. You can even use
something like SQLite
to have a persistent database, and
you can read/write from any files you have access to. The script will be
run as your user, and the working directory will always be set to
~/public/cgi-bin
.
Be careful with this. Remember that anyone in the entire world can trigger the script to run.
There's a lot of information that's passed to your script through the
environment. For example the query parameters can be accessed by reading
QUERY_STRING
.
You can do some cool things with the headers. For example, you can use redirects:
#!/usr/bin/bash
# suppose this is saved at /home/foo/public/cgi-bin/redirect.sh
# Send headers
echo "Status: 302 Found"
echo "Location: https://www.google.com"
echo "Content-Type: text/html"
echo
echo
Now navigating to
https://moontowercomputer.club/~foo/cgi-bin/redirect.sh
should trigger the browser to redirect to
https://www.google.com
. Remember that even the redirect is
generated by the script, so while it's just a static redirect here, you
could do anything - in theory you could make your own URL shortening
service or something.
You should make sure to set the appropriate MIME type. See https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types
for more info. For most text-based things, you'll probably want
Content-Type: text/html
.
Hello rustaceans! Rust is awesome, but takes up so much space. So
we're going to share, and we're going to use a system-wide install of
rust. It's present at /opt/rust
.
Here's a snippet from my fish config that I use to access rust tools, you'll have to figure out the equivalent for your shell.
source "/opt/rust/env.fish"
set -x RUSTUP_HOME /opt/rust
Note that you'll still have ~/.cargo
for anything you
build or install yourself, the only thing that's shared is the rust
toolchain. If you decide that you're not a morally upright person who is
okay with really eating up our shared disk space (or if you just need a
specific or non-stable toolchain version) , you can always unset
RUSTUP_HOME
, run rustup default stable
(or
whatever version/tag of rust you want), and it'll install it to your
home directory. I'd recommend that you build elsewhere and cross compile
though - the compute resources on moontower
are also pretty
limited, so it's really not a great development experience. Rust isn't
necessarily installed here to facilitate development so much as just
providing access to utilities installable through
cargo
.