Automating SSH Connection between Two Windows 10 Systems using Open-SSH and Ubuntu VirtualBox
This article will guide you through the process of automating SSH connections between two Windows 10 systems, one of which is installed as a virtual machine using Oracle VirtualBox. By the end of this article, you will be able to establish an SSH connection between the two systems without the need for manual intervention.
Prerequisites
- Two Windows 10 systems
- Oracle VirtualBox installed on one of the systems
- Ubuntu installed as a virtual machine on the system with VirtualBox
Installing Open-SSH on Ubuntu
Open-SSH is a suite of security-related network-level utilities based on the Secure Shell (SSH) protocol. It is used to secure network communications and enable remote command execution. To install Open-SSH on Ubuntu, follow these steps:
- Open a terminal window in Ubuntu
- Update the package list by running the following command:
sudo apt-get update - Install Open-SSH by running the following command:
sudo apt-get install openssh-server - Check the status of the Open-SSH server by running the following command:
sudo systemctl status ssh
Configuring SSH on Ubuntu
After installing Open-SSH, you need to configure it to allow remote connections. To do this, follow these steps:
- Open the SSH configuration file by running the following command:
sudo nano /etc/ssh/sshd_config - Find the line that starts with
#PermitRootLoginand change it toPermitRootLogin yes - Find the line that starts with
#PasswordAuthenticationand change it toPasswordAuthentication yes - Save the changes and exit the editor
- Restart the SSH service by running the following command:
sudo systemctl restart ssh
Configuring Windows 10 for SSH
To enable SSH on Windows 10, you need to install the OpenSSH client. To do this, follow these steps:
- Open the Windows Settings app
- Go to
Apps > Apps & features > Optional features - Click on
Add a feature - Find and select
OpenSSH Client - Click on
Install
Automating SSH Connections
To automate SSH connections between the two Windows 10 systems, you can use a utility called plink.exe, which is part of the PuTTY suite. plink.exe can be used to establish an SSH connection and run commands remotely.
First, you need to generate a pair of SSH keys on the Windows 10 system that will be used to connect to the Ubuntu virtual machine. To do this, run the following command:
ssh-keygen -t rsaThis will generate two files: id_rsa (private key) and id_rsa.pub (public key).
Next, copy the public key to the Ubuntu virtual machine. To do this, run the following command:
ssh-copy-id -i id\_rsa.pub [user]@[ubuntu\_ip]Replace [user] with the username on the Ubuntu virtual machine and [ubuntu\_ip] with the IP address of the Ubuntu virtual machine.
Finally, create a batch file on the Windows 10 system that will be used to establish the SSH connection. The batch file should contain the following command:
plink.exe -ssh [user]@[ubuntu\_ip] -i id\_rsa "command"Replace [user] with the username on the Ubuntu virtual machine, [ubuntu\_ip] with the IP address of the Ubuntu virtual machine, and command with the command that you want to run on the Ubuntu virtual machine.
- Installed Open-SSH on Ubuntu and configured it to allow remote connections
- Installed the OpenSSH client on Windows 10
- Generated a pair of SSH keys on Windows 10 and copied the public key to Ubuntu
- Created a batch file on Windows 10 to establish an SSH connection and run commands on Ubuntu