Skip to content

Instantly share code, notes, and snippets.

@Skylarity
Last active February 23, 2017 16:09
Show Gist options
  • Save Skylarity/fe6b5d2f1ddab025f71d5c432adb9003 to your computer and use it in GitHub Desktop.
Save Skylarity/fe6b5d2f1ddab025f71d5c432adb9003 to your computer and use it in GitHub Desktop.
Notes for RS21 server administration.

Server Admin Crash Course

Logging in

SSH

SSH stands for Secure Shell. It's a network protocol by which you can operate devices remotely over the World Wide Web. 👻 spooky 👻

Windows

You're going to need PuTTY to be able to SSH into anything.

Setting up your key

Once PuTTY is installed, we need to create a key.

  1. Open PuTTYGen.
  2. Click Generate.
  3. Wave your mouse around the little box like an idiot. PuTTYGen is using the (x, y) coords to generate a random key.
  4. Enter a passphrase to protect the key.
  5. Click Save private key and save your private key.
  6. Click Save public key and save your public key.

Your public key will live on the server, and your private key will live on forever in our hearts RIP- I mean, live on your machine.

Connecting via SSH

First, we've gotta set up the connection. We (thankfully) only have to do this once per machine.

  1. Open PuTTY.
  2. In the Host Name box, put yourusername@rs21.io.
  3. Go to Connection > SSH > Auth, and browse for your private key file in the Private key file for authentication box
  4. Go back to Session tab, and enter a name for this configuration in the text box under Saved Sessions.
  5. Click Save.

Now we can actually connect to the server.

  1. Open PuTTY if it's not open already.
  2. Double-click on your save RS21 session. 2. The first time this happens you may get a warning about PuTTY never having seen that host before or something, you can click Yes or Okay or whatever.

Any other sane OS

Setting up your key
  1. Export your key in a format *nix machines know what to do with.
    1. Open PuTTYGen.
    2. Load your key.
    3. Go to Conversions > Export OpenSSH key.
    4. Save the file.
  2. Make sure your machine knows what key to use: mv yourkeyfilehere.openssh ~/.ssh/id_rsa (this moves the file to the proper directory within your home directory and renames it to id_rsa, the default key name on *nix systems).

(This should work, but I haven't tested it.)

Connecting via SSH

Run ssh yourusername@rs21.io into your terminal. That's it. You're done.

Basic Commands

WTF is sudo

You're going to need root-level access to do some things, especially when dealing with the web server side of stuff. Preface your commands with sudo and they will be executed as root-level commands. You'll need to enter your password the first time you run a sudo command in a session.

sudo stands for Super User Do.

How to look at the contents of a directory

Run the list command: ls. This will print out the files and folders within the directory you are in.

You can also run ls some/path. Guess what that will do.

Sometimes, there are hidden files within a directory. Run ls -a to show them.

How to create files and folders

Files

There are two ways to create files.

  1. touch filename.whatever
  2. vim filename.whatever or nano filename.whatever or yourtexteditorhere filename.whatever

The second command will open the file in said text editor after creation.

Folders (Directories)

To create a directory, run mkdir yourdirectoryname.

How to copy/move files

Copying files

To copy files, run cp path/to/file.txt path/to/destination/

Moving files

To copy files, run mv path/to/file.txt path/to/destination/

Copying/Moving directories

To copy/move directories, run cp -R path/to/directory/ path/to/destination/ or mv -R path/to/directory/ path/to/destination/ respectively.

The -R flag means it will recursively look through the file tree to move the entire contents of the directory.

How to access the PGSQL database

To access the PostgreSQL database, you must be the postgres user.

  1. SSH into the server.
  2. To switch user, run sudo su postgres. This will use the switch user command to log you in as postgres.
  3. Run psql.
  4. Have fun.*

* Required step

How to host things on the portal

FTP transfer

FTP stands for File Transfer Protocol.

On Windows we'll need a program called Cyberduck to do our FTP stuff for us. Download and install it.

  1. Click Open Connection.
  2. At the top, select SFTP. This is the Secure File Transfer Protocol.
  3. For Server, enter rs21.io
  4. For Username, enter your username. Wow.
  5. Don't enter a password, but do select your SSH key down at SSH Private Key.
  6. Click Connect.
  7. Drag and drop to your heart's content.

Where to stick files you want to be on the portal

The proper destination for webapps that need to be on the portal is /var/www/rs21.io/portal/webappname/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment