How to install OpenSSH on Windows Server 2016 VM on CloudFerro Cloud

../_images/button_orange_cf23.png

Prerequirements

  • Windows Server 2016 VM must be created,

  • allow_ping_ssh_rdp security group must be allocated,

  • Floating IP address must be associated.

What We Are Going To Do

  • Download and install OpenSSH,

  • Allow access in Windows Firewall,

  • Connect to Windows via SSH from Linux or Windows,

  • Access files via SFTP.

Download and install OpenSSH

  1. Log in to your VM via RDP

  2. Download the newest OpenSSH server from GitHub ( https://github.com/PowerShell/Win32-OpenSSH/releases )

In our case it is v8.1.0.0p1-Beta, 64-bit version.

../_images/image011.png

If you can not download the file you can change security settings.

../_images/image013.png

Go to “Control Panel” → “Network and Internet” → “Internet Options” and choose “Security” tab.

../_images/image014.png

Click the Custom level… button.

../_images/image015.png

Find the “Downloads” section and change the “File download” option to “Enable” then click OK.

../_images/image016.png

Confirm by clicking Yes then click Apply.

../_images/image017.png

Now you can download the file.

../_images/image018.png
  1. Open the downloaded file and copy the “OpenSSH-Win64” folder to “C:Program Files”.

../_images/image019.png
  1. Go to “C:Program FilesOpenSSH-Win64” and edit the “sshd_config_default” file.

../_images/image020.png ../_images/image021.png
  1. Find and uncomment following lines by removing the “#” at the beginning then save the file.

#Port 22
#PasswordAuthentication yes

After the changes it should be:

Port 22
PasswordAuthentication yes

6. Now you have to modify system environment variable. To do it run Windows PowerShell as administrator …

../_images/image22.png

… and type the following command:

setx PATH "$env:path;C:\Program Files\OpenSSH-Win64" -m

You should see the output “SUCCESS: Specified value was saved.”.

../_images/image034.png
  1. Change to the OpenSSH directory and run the install script.

cd "C:\Program Files\OpenSSH-Win64"; .\install-sshd.ps1
../_images/image23.png
  1. Enable automatic startup and start “sshd” and “ssh-agent” services.

Set-Service sshd -StartupType Automatic; Set-Service ssh-agent -StartupType Automatic; Start-Service sshd; Start-Service ssh-agent

Allow access in Windows Firewall

We have to add new firewall rule to open port which we will use to connect via SSH, default is 22.

To add the rule just run the following command in Windows PowerShell.

New-NetFirewallRule -DisplayName "OpenSSH-Server-In-TCP" -Direction Inbound -LocalPort 22 -Protocol TCP -Action Allow
../_images/image24.png

Connect to Windows via SSH

From Linux

Connect to the VM by typing the following command in terminal. Remember to type your VM’s IP address.

ssh Administrator@<your-vm-ip-address>

Type the password.

If you are connected you should be in Administrator’s home directory.

../_images/image025.png

From Windows (via Putty)

Open Putty and create new session. Complete the fields as below.

Host Name for IP address: Administrator@<your-vm-ip-address> Port: 22 Connection type: SSH Saved Sessions: <your-vm-name>

Click Save button.

../_images/image026.png

Double click on your new saved session to connect then click Yes.

../_images/image027.png

Now you are connected to your Windows VM via SSH.

../_images/image028.png

Accessing files via SFTP

WinSCP

Prerequirements

  • WinSCP must be installed

Open WinSCP and click New Session.

../_images/image029.png

Complete fields as below and click Save.

Host name: <your-vm-ip-address> Port number: 22 User name: Administrator Password: <your-password>

../_images/image030.png

Click OK. You can also save your password.

../_images/image031.png

Confirm by clicking Yes.

../_images/image032.png

Now you can browse your files.

../_images/image033.png