Difference between revisions of "Set up a Virtual Private Server"

From Parallel Library Services
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
https://hetzner.com
Difficulty: ** (medium)


Internet service providers such as hetzner.com offer ways to host servers online. Their virtual private servers are useful to run websites with particular processing and traffic settings.
A VPS (Virtual Private Server) is useful to run websites with particular processing and traffic needs; such as wikis and other dynamic websites that rely on database queries to render HTML on the fly. Companies such as https://hetzner.com offer these services, with a fairly simple setup through a registered account.
 
== Getting started ==


On the page https://hetzner.com/cloud there is an overview of what options are available for a VPS, including location, CPU speed, and options to extend storage:
On the page https://hetzner.com/cloud there is an overview of what options are available for a VPS, including location, CPU speed, and options to extend storage:
Line 11: Line 13:
[[File:hetzner_login.png|600px]]
[[File:hetzner_login.png|600px]]


==  Creating a new project and adding servers ==
Once you have created your account and logged in, you will be presented with your ‘Projects’ screen, which groups VPSs together into common uses or projects. Make a new project and name it.  
Once you have created your account and logged in, you will be presented with your ‘Projects’ screen, which groups VPSs together into common uses or projects. Make a new project and name it.  


Line 41: Line 44:
# name of server - parallel-wiki
# name of server - parallel-wiki


If public [[SSH: Secure Shell|SSH]] keys are not added at setup, you will receive the root password via email. I chose to add my public SSH key by copying the file on my computer in the path <code>~/.ssh/id_rsa.pub</code>.  
If public [[SSH: Secure Shell|SSH]] keys are not added at this step, you will receive the root password via email. If you do add a key, you can still find and change the root password through the cloud console in the browser at a later stage. I chose to add my public SSH key by copying and pasting the contents of the file on my computer in the path <code>~/.ssh/id_rsa.pub</code>.  


[[File:hetzner_ssh.png|600px]]
[[File:hetzner_ssh.png|600px]]


When you are ready, click "create and buy now", and the server will be initialised. Make a note of the IP address of the server, to finish the SSH configuration.
When you are ready, click "create and buy now", and the server will be initialised. Make a note of the IP address of the server.  


I edited my SSH configuration file on my computer, found at <code>~/.ssh/config</code>. Your config should look something like this, with the correct IP address of the server in the "Hostname" field.
Now you have a server set up, the last step is to set SSH configuration on your computer for secure, remote access.
 
=== SSH configuration ===
 
I edited my SSH configuration file in the path <code>~/.ssh/config</code> on my computer. Your config should look something like this, with the correct IP address of the server in the "Hostname" field:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 58: Line 65:
</syntaxhighlight>
</syntaxhighlight>


With this configuration, I can use SSH to access the server by typing one line:
Once done editing, save and close the file. With this configuration, I can use SSH to access the server by typing one line:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ssh parallel-wiki
ssh parallel-wiki
</syntaxhighlight>
</syntaxhighlight>
A good, detailed guide to bootstrapping a VPS with hetzner.com is on this page:
http://the-internet-101.com/how-to-setup-a-vps-with-hetzner


[[Category:Cookbook]]
[[Category:Cookbook]]

Latest revision as of 18:03, 14 November 2021

Difficulty: ** (medium)

A VPS (Virtual Private Server) is useful to run websites with particular processing and traffic needs; such as wikis and other dynamic websites that rely on database queries to render HTML on the fly. Companies such as https://hetzner.com offer these services, with a fairly simple setup through a registered account.

Getting started

On the page https://hetzner.com/cloud there is an overview of what options are available for a VPS, including location, CPU speed, and options to extend storage:

Hetzner cloud.png

Click "login" at the top right, choose "cloud" and then in the new page that opens, enter your username and email address as per your registration.

Hetzner login.png

Creating a new project and adding servers

Once you have created your account and logged in, you will be presented with your ‘Projects’ screen, which groups VPSs together into common uses or projects. Make a new project and name it.

Hetzner projects.png

A message will flash saying that the project has been created. Click on the newly created project to begin making choices for:

  1. location
  2. image, with choices for OS images and apps
  3. type
  4. volumes
  5. network
  6. firewalls
  7. additonal features
  8. ssh keys
  9. name of server

Hetzner server options.png

For an installation of a wiki, my choices were:

  1. location - Nuremberg
  2. image, with choices for OS images and apps - Debian 11
  3. type - standard, CX21
  4. volumes - no selection
  5. network - no selection
  6. firewalls - no selection
  7. additonal features - no selection
  8. ssh keys - added my public key (see below)*
  9. name of server - parallel-wiki

If public SSH keys are not added at this step, you will receive the root password via email. If you do add a key, you can still find and change the root password through the cloud console in the browser at a later stage. I chose to add my public SSH key by copying and pasting the contents of the file on my computer in the path ~/.ssh/id_rsa.pub.

Hetzner ssh.png

When you are ready, click "create and buy now", and the server will be initialised. Make a note of the IP address of the server.

Now you have a server set up, the last step is to set SSH configuration on your computer for secure, remote access.

SSH configuration

I edited my SSH configuration file in the path ~/.ssh/config on my computer. Your config should look something like this, with the correct IP address of the server in the "Hostname" field:

# parallel-wiki
Host parallel-wiki
Port 22
User root
Hostname X.X.X.X
Identityfile ~/.ssh/id_rsa

Once done editing, save and close the file. With this configuration, I can use SSH to access the server by typing one line:

ssh parallel-wiki