vServer Setup Guide
Welcome to the vServer setup guide!
This document will guide you through setting up SSH keys, configuring an Nginx web server, and connecting your server to GitHub.
Table of Contents
1. Setup SSH Key Connection
1.1 Create Project
Create a separate folder for each project:
Bash
mkdir ~/.ssh/project_folder
Powershell
mkdir C:\Users\user\.ssh\subfolder
1.2 Generate a new SSH key:
Bash
ssh-keygen -t ed25519 -C "user@mail.com" -f ~/.ssh/project_folder/filename
Powershell
ssh-keygen -t ed25519 -C "user@mail.com" -f C:\Users\user\.ssh\subfolder\filename
-ttype of Key you can also choose another one-CComment to identify your key-fspecifies the file path and name for storing the key file
You do not need to enter a passphrase and can skip entering it by pressing Enter. It is recommended to increase security.
Enter passphrase:
Now you have 2 new files in your folder
- Private Key "filename" | ONLY for YOU
- Public Key "filename.pub" | to share
1.3 Save the created key on the server
Copy the desired key to the server.
Bash
ssh-copy-id vserver-user@vserver_ipv4
Powershell
- Copy the key to your server in the home directory of the server user
scp C:\Users\user\.ssh\subfolder\filename.pub user@vserver_ipv4:~
- Login on your vServer with
ssh user@vserver_ipv4
- Write your public-key in authorized_keys flie
cat filename.pub >> .ssh/authorized_keys
- Delete with remove your public-key file
rm ~/filename.pub
- Print the contents of the file to check if everything worked.
cat ~/ssh/authorized_keys
ssh-ed25519 AAAAC3NzaC1lZFFAA13645B23AAAAIFE7TXS31fHp+/MbA4YlX4cG2OTQStMtX3R6+TDssBk0 user@mail.com
1.4 Check Connection
Test the login with the public keyn to connect on the server via sshkey.
Bash
ssh -i ~/.ssh/subfolder/filename vserver-user@vserver_ipv4
Powershell
ssh -i C:\Users\user\.ssh\subfolder\filename user@server_ipv4
-iidentity file by the path to your private key
1.5 Setup a short alias for connection
Create on your local machine a ./ssh/config file
Host serverAlias
HostName hostname or IPv4
User user
IdentityFile ~/.ssh/subfolder/filename
Now you can use Bash or Powershell to connect via alias
ssh serverAlias
1.6 Update vServer connection rules
Login with key & passphrase
ssh serverAlias
Enter passphrase for key 'C:\Users\user\.ssh\subfolder\filename':
Open the SSH configuration file with the text editor nano. You can only change the file if you have root rights. Confirm root rights, enter the user password.
sudo nano /etc/ssh/sshd_config
Find PasswordAuthentication
#PasswordAuthentication yes
Change it to
PasswordAuthentication no
Save file & Exit file in nano
- Save file
STRG + O - Exit file
STRG + X
Make the changes effective, the service must be restarted.
sudo systemctl restart sshd
2. Configure Nginx Web Server
2.1 Install Nginx
Update your system and install Nginx:
sudo apt-get Update && sudo apt-get upgrade -y
sudo apt-get install nginx -y
Open your browser an navigate to "http://server_ipv4", you can see the nginx.defautl webpage.

2.2 Configure Nginx
Remove the default folder & file:
sudo rm -r /var/www/html/
Create a new project directory:
sudo mkdir /var/www/my_page
Add an index.html file:
sudo nano /var/www/my_page/index.html
Example content:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MY_PAGE</title>
<style>
body {
background-color: darkblue;
}
h1 {
color: white;
}
</style>
</head>
<body>
<h1>Welcome to my-page</h1>
</body>
</html>
Copy the default file to save the settings
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default_copy
Remove file link
sudo rm /etc/nginx/sites-enabled/default
Rename the default file to my_page
sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/my_page
Open the my_page file with nano
sudo nano /etc/nginx/sites-available/my_page
Add your nginx webserver configuration
server {
listen 8081;
root /var/www/my_page;
index index.html;
server_name server_ipv4 hostname;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
Save file & Exit file in nano
- Save file
STRG + O - Exit file
STRG + X
Create a symlink to enable your configuration
sudo ln -s /etc/nginx/sites-available/my_page /etc/nginx/sites-enabled/
Test your nginx settings
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Adjust user rights for the project for nginx
sudo chown -R www-data:www-data /var/www/my_page/
Restart Nginx service to apply the settings
sudo systemctl restart nginx
Open your browser an navigate to "http://server_ipv4:8010", now you can see your webpage.
3. Connect to GitHub
3.1 Install Git
Install Git on your server
sudo apt-get install git -y
3.2 Set Up GitHub SSH Key
Generate a new SSH key for the server:
ssh-keygen -t ed25519 -C "hostname"
Display the public key:
cat ~/.ssh/id_ed25519.pub
Add the key to your GitHub account:
GitHub > Settings > SSH and GPG keys > New SSH Key
3.3 Configure Git
Set up your Git username and email:
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
Now you have full access to your GitHub account and can clone repositories, work on them and upload them again.
git clone git@github.com:YourName/vServer_setup.git
Done!
Your vServer is now configured with SSH, an Nginx web server, and GitHub integration.