Zum Hauptinhalt springen

V-Server Setup

This page documents how I configured my very first cloud server instance in the Developer Akademie DevSecOps Course.

TOC​

team-collaboration/version-control/githubGithub Tip

πŸ–₯️ V-Server Setup Guide​

This documentation describes step-by-step how to configure your own Ubuntu-based V-Server – including SSH setup, NGINX web server, GitHub integration, and security best practices.


πŸ”§ Requirements​

  • An Ubuntu server (e.g., from Hetzner, Netcup, AWS)
  • SSH access to the server
  • A GitHub account

πŸ“Œ Step 1: SSH Key-Based Login​

  1. Generate an SSH key pair (on your local machine):

    ssh-keygen -t ed25519
  2. Copy your public key to the server:

    ssh-copy-id user@server-ip
  3. Now connect to your server without a password:

    ssh user@server-ip

πŸ”’ Step 2: Disable Password Login​

  1. Open the SSH configuration file:

    sudo nano /etc/ssh/sshd_config
  2. Change or add the following lines:

    PasswordAuthentication no
    PermitRootLogin no
  3. Restart SSH:

    sudo systemctl restart ssh

βœ… Make sure your SSH key login works before disabling password login!


🌐 Step 3: Install and Configure NGINX​

  1. Install NGINX:

    sudo apt update
    sudo apt install nginx
  2. Create a directory for your custom homepage:

    sudo mkdir -p /var/www/myhomepage
  3. Create an HTML file:

Option A – Quick version with echo:

echo "Hello, NGINX! I have just configured our NGINX web server on Ubuntu Server!" | sudo tee /var/www/myhomepage/index.html

Option B – Manual edit with nano:

sudo nano /var/www/myhomepage/index.html

Example content:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My NGINX Homepage</title>
</head>
<body>
<h1>Hello from my own homepage!</h1>
<p>This is a custom HTML page served by NGINX.</p>
</body>
</html>
  1. Configure NGINX to serve the custom page:

    sudo nano /etc/nginx/sites-available/default

    Change:

    root /var/www/myhomepage;
    index index.html;
  2. Restart NGINX:

    sudo systemctl restart nginx

πŸ§ͺ Test Your Setup​

Open your browser and go to:

http://<your-server-ip>

βœ… You should see your custom HTML page.


πŸ” Step 4: Set Up Git and GitHub​

  1. Install Git (if not already installed):

    sudo apt install git
  2. Configure Git with your name and email:

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"

πŸ” Set up SSH Connection to GitHub (important!)

  1. Generate a new SSH key on the server (VM):
ssh-keygen -t ed25519 -C "your_email@example.com"
  1. Start the SSH agent and add the key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
  1. Show your public key:
cat ~/.ssh/id_ed25519.pub
  1. Now go to GitHub β†’ Settings β†’ SSH and GPG Keys β†’ New SSH Key Paste the copied public key and give it a name (e.g., v-server).

  2. Test the connection:

ssh -T git@github.com

You should see:

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.
  1. Initialize a new Git repository:

    git init
    git add .
    git commit -m "Initial commit"
  2. Push to GitHub:

    git remote add origin https://github.com/YOUR-USERNAME/v-server-setup.git
    git push -u origin main
  3. Create a new branch:

    git checkout -b improved-readme
  4. Make changes, push the branch, and open a Pull Request βœ…


πŸ“¦ Summary​

  • βœ… Secure login using SSH key
  • βœ… Password login disabled
  • βœ… NGINX web server with custom homepage
  • βœ… Git and GitHub integration completed