Skip to content

Setting Up 🖥️ A Virtual Machine

In this guide, you'll learn how to set up and manage a virtual machine (VM). A VM is an essential tool for isolating environments, testing new configurations, and running applications without affecting your main system. This guide will walk you through the process step by step.

Manage the VM

Need Help?

If you ever get stuck or run into trouble, don't hesitate to contact the "mods" on Discord or just send a message in the server! 💬

Useful Tips on Variables

When filling out the values of the variables, don't include the <> but fill in the appropriate value.

<local-username>: The local username on your computer

<vm-manager-ip>: 130.208.246.206

<vm-ip>: The IP of the VM you created via VM Manager

<priv-key-path>: This should be the path to your private SSH key. (do not include .pub). For example, if your key is stored in C:\Users\YourUsername\.ssh\id_rsa, you would specify that as the path.

<username>: The username created for you on the VM (Sent to you after you send us your SSH key)

Available commands within VM Manager

vm-manager.py show -> Shows information about VMs running

vm-manager.py create -> Create VM

vm-manager.py start -> Start VM

vm-manager.py stop -> Stop VM

vm-manager.py delete -> Delete VM

A. Generate a SSH key

If you have not already created a ssh-rsa key, follow these instructions.

B. Send the public SSH key to us

After generating the key, (for now) we will need to create your account. Please send the "mods" on Discord the key .pub key.

C. Connect to the VM Manager

Connecting to the VM Manager

In your terminal, type..

1
2
3
4
ssh -i <priv-key-path> <username>@<vm-manager-ip>

# Example
ssh -i \users\JohnJohnsson\.ssh\id_rsa John@130.208.246.206

Run powershell as admin and type..

1
2
3
4
ssh -i <priv-key-path> <username>@<vm-manager-ip>

# Example
ssh -i C:\Users\JohnJohnsson\.ssh\id_rsa John@130.208.246.206

You will get a prompt Are you sure you want to continue connecting (yes/no/[fingerprint])?. Write yes.

Then the prompt Enter passphrase for key 'C:\Users\Username/.ssh/id_rsa': will come up and there you enter your password for the key. Remember this password to be able to use the key.

See all available commands within VM Manager here

D. Create and start your VM

1. Create your VM

vm-manager.py create

You will have to wait for it to finnish setting up and will recieve the prompt VM started successfully. when it's done.

2. Show VM to see the IP

vm-manager.py show

There you see in the output on the terminal something something like:

1
2
3
603. cysec-<username> => running
Interface: lo, IPs: 127.0.0.1, ::1
Interface: ens18, IPs: 130.208.246.2XX, fe80::be24:11ff:fe33:b353

Take note of the IP located at 130.208.246.2XX. That is your <vm-ip>

  • (XX is a placeholder for the rest of the ip since this can vary between users)

2. SSH Configuration

A. Editing your config file

If you are still connected to the VM start by logging of the session like so:

John@CySecGate:~$ exit

1. Backup the Config

Open Terminal to create a backup of your config file. If you the file does not exist, continue with the next step.

cp /home/<username>/.ssh/config /home/<username>/.ssh/config.bak

2. Edit/Create the SSH Config File

Edit the local config file on your computer

nano /home/<local-username>/.ssh/config
# (you can find your username using the command `whoami`)

Once the file is open, you can add the following configuration:

1
2
3
4
5
6
7
8
9
Host cysecgate
    user <username>
    Hostname <vm-manager-ip>

Host cysec-<username>
    user <username>
    ProxyJump cysecgate
    Hostname <vm-ip>
    Port 4242

(See variables at the top of this page if you are confused what to replace the contents of <> with )

3. Save changes

To do so, press:

Control + X than write Y

1. Backup the Config

First, check if the SSH config file already exists by running this in PowerShell:

Test-Path C:\Users\<username>\.ssh\config

If the config file does not exist, create it:

New-Item C:\Users\<username>\.ssh\config -ItemType File

If the config file already exists, create a backup to avoid losing your current settings:

Copy-Item C:\Users\<username>\.ssh\config C:\Users\<username>\.ssh\config.bak

2. Edit the SSH Config File

Open the config file in a text editor like Notepad:

notepad C:\Users\<username>\.ssh\config

Once the file is open, you can add the following configuration:

1
2
3
4
5
6
7
8
9
Host cysecgate
    user <username>
    HostName <vm-manager-ip>

Host cysec-<username>
    User <username>
    ProxyJump cysecgate
    HostName <vm-ip>
    Port 4242

Replace <username>, <vm-manager-ip>, and <vm-ip> with the variables found at the top of this document.

3. Save changes

Save and exit the editor when done.

B. Create agent and assign private key to it

Creating an SSH agent allows you to securely manage your SSH keys without needing to enter the passphrase each time you connect to a VM. Follow these steps to set up and use an agent:

  1. Create the agent
eval "$(ssh-agent -s)"
  1. Assign your private key to the agent
ssh-add <priv-key-path>
  1. Start the SSH Agent:
Start-Service ssh-agent

This starts the SSH agent service. If it's already running, you'll be notified.

Note: If this does not work, you can try the following command and then try again Get-Service -Name ssh-agent | Set-Service -StartupType Manual

  1. Add Your Private Key to the Agent:
ssh-add C:\Users\<username>\.ssh\id_rsa

Replace C:\Users\<username>\.ssh\id_rsa with the actual path to your private SSH key file.

  1. To verify that your key has been added, you can run:
ssh-add -l

C. Connect to the VM

Now, having done the previous steps you should be able to connect to the VM!

  1. Connect with ssh
ssh cysec-<username>

Now you should be in! 🥳

  1. Connect via ssh
ssh cysec-<username>

Now you should be in! 🥳