Virtual Machine Setup
Steps to create a virtual machine:- Download a hypervisor:
- Go to VirtualBox or VMware. Download and install the software on your machine.
- Obtain an OS image:
- Download the required ISO file for the operating system.
- Create the virtual machine:
- Open VirtualBox/VMware app.
- Create a new virtual machine according to requested specification.````
- Configure name, OS type, hardware settings like RAM, CPU, and disk space.
- Install the OS
- Start the virtual machine.
- Follow the installation steps in the OS setup wizard.
- Connect to the VM:
- For Linux VMs: Enable SSH in the VM during installation or after setup.
- Use SSH (on Linux/Mac) or tools like PuTTY (on Windows) to connect.
- Additional steps:
- Windows VM Remote Desktop:
- Enable Remote Desktop in the Windows VM settings. Use the RDP client, configuration described here >> Remote Desktop clients for Remote Desktop Services and remote PCs on your host machine to connect.
- Connect RDP client to remote machine.
- Windows VM Remote Desktop:
- Download a hypervisor:
Windows Services Management in PowerShell.
Task:
- Print list of services
- Run specific service
- Stop specific service
- Restart specific service
- Check status for specific service
To get list of running services I will use :
1
Get-Service | Where-Object {$_.Status -eq 'Running'}
Assuming that I want to run
"WSLService"
To start
"WSLService"
service I’m using :
1
Start-Service -Name "WSLService"
To stop the service:
1
Stop-Service -Name "WSLService"
For restarting service:
1
Restart-Service -Name "WSLService"
For checking the status of monitored service:
1
Get-Service -Name "WSLService"
SSH connection to the Linux machine actions are below.
I added more information in advance because the original task does not contain information about the client machine from which the connection to the Linux machine will be made. There is 3 different cases:
- Case 1: From another Linux client to Linux host
- Case 2: From a Windows client to Linux host
- Case 3: From macOS client to Linux host
For Linux/Mac: SSH is usually pre-installed but if it’s missing install an SSH client (e.g. on Ubuntu):
1
sudo apt install openssh-client -y
After installation, start the service on Linux machine:
1
sudo systemctl start ssh
If SSH service not started , checked its status on Linux machine:
1
sudo systemctl status ssh
Generate SSH keys (on the host machine):
1
ssh-keygen -t rsa -b 2048
The keys will be stored in ~/.ssh/id_rsa (private) and ~/.ssh/id_rsa.pub (public).
Copy the public key to the Linux server:1
ssh-copy-id user@server_ip
Or manually append the content of id_rsa.pub to ~/.ssh/authorized_keys on the server.
Connection via SSH for Linux:
1
ssh user@server_ip
Optional Configurations:
Edit the SSH config file (~/.ssh/config) for aliases:
1
2
3
4Host server_alias
HostName server_ip
User username
IdentityFile ~/.ssh/id_rsaThis will simplify the connection:
1
ssh server_alias
Case 1: From another Linux client to Linux host
Verify SSH Client on the Local Machine:
- Most Linux distributions come with the ssh client pre-installed. Confirm by running:If it’s not installed, install it:
1
ssh -V
1
sudo apt install openssh-client
Replace <username>
with the remote machine’s username.
Replace <remote_ip>
with the target machine’s IP address.
- Use Public Key Authentication (Optional):
1
ssh-keygen
- Copy the public key to the remote machine:
1
ssh-copy-id <username>@<remote_ip>
- Now, log in without entering a password:
1
ssh <username>@<remote_ip>
Case 2: From a Windows client to Linux host
Install an SSH Client:
- Use the built-in OpenSSH client on Windows 10+. Open PowerShell or Command Prompt and check if SSH is installed:
1
ssh -V
- For Windows alternatively install OpenSSH client from “Optional Features” or download PuTTY( third-party SSH client).
- Use the built-in OpenSSH client on Windows 10+. Open PowerShell or Command Prompt and check if SSH is installed:
Connect Using OpenSSH (Built-in).
Open PowerShell or Command Prompt and run:
1
ssh <username>@<remote_ip>
Connect Using PuTTY:
- Download and install PuTTY.
- Open PuTTY and enter the hostname or IP address.
- Set the Port to 22 and click Open.
- Log in with your credentials.
- Enable Key Authentication (Optional):
- Use puttygen to generate a private/public key pair.
- Copy the public key to the Linux machine’s ~/.ssh/authorized_keys.
- In PuTTY, configure the private key in Connection > SSH > Auth > Browse Private Key.
Case 3: From macOS client to Linux host
Verify SSH Client:
macOS includes an SSH client by default. Confirm it by running:
1
ssh -V
Connect to the Linux Machine:
Open Terminal and run:
1
ssh <username>@<remote_ip>
Use Public Key Authentication (Optional):
1
ssh-keygen
Copy the public key to the remote machine:
1
ssh-copy-id <username>@<remote_ip>
Now, I can log in without entering a password:
1
ssh <username>@<remote_ip>