This project contains scripts to enable VPN and/or SSH on Azure VM with command line. You don't need to re-configure VPN or SSH again and again when you want to recreate a VM or the network adapter changed.
- Create a new Azure VM with nessesary NSG rules with command line
- Set up VPN on Windows Server
- Set up SSH server
- Configure remote desktop certificate
- Deploy a new VM with nessesary NSG rules
-
Update parameters in
AzureVMDeployment\parameters.json
for your to be created VM. This file includes parameters such as VM name, location, username and password, storage account name. -
Run below Powershell script. (Insure you have installed
Microsoft Azure Powershell
.)pushd .\AzureVMDeployment\ .\deploy.ps1 -subscriptionId "your_subscription_id_here" -resourceGroupName "your_resource_group_name_here" -resourceGroupLocation "your_resource_group_location_here" -deploymentName "your_deployment_name_here" popd
-
- Configure VPN server
-
Use remote desktop to log on to the VM you want to enable VPN.
-
Copy files in
Config\Server
to any folder of the VM. -
Copy the certificate (.pfx) you want to use to the VM.
-
In the VM, run below Powershell script at the folder where you copied files of step 2. You'll be prompted to type the password of the pfx file.
$cert = .\InstallCert.ps1 -pfxPath "your_certificate_file_path" .\ConfigureVPN.ps1 -thumbprint $cert.Thumbprint -preSharedKey "your_presharedkey_for_l2tp_ipsec_here"
-
- Configure SSH server
-
Use remote desktop to log on to the VM you want to enable VPN.
-
Copy files in
Config\Server
to any folder of the VM. -
Optionally, copy your exported Bitvise SSH server settings file to any folder the VM.
-
In the VM, run below Powershell script at the folder where you copied files of step 2.
.\ConfigureSSH.ps1 -sshSettingPath "your_bitvise_ssh_server_settings_file.wst"
If you don't have a previously exported Bitvise SSH server settings file, just run above command without
-sshSettingsPath
parameter. -
If it's your first time to configure SSH, the VM will restart automatically. Just wait.
-
- Configure remote desktop certificate
-
Use remote desktop to log on to the VM you want to enable VPN.
-
Copy files in
Config\Server
to any folder of the VM. -
Copy the certificate (.pfx) you want to use to the VM.
-
In the VM, run below Powershell script at the folder where you copied files of step 2. You'll be prompted to type the password of the pfx file.
$cert = .\InstallCert.ps1 -pfxPath "your_certificate_file_path" .\ConfigureRDP.ps1 -thumbprint $cert.Thumbprint
-
- Configure VPN client
-
On your client machine, run below Powershell script.
.\Config\Client\ConfigureVPNClient.ps1 -name "your_vpn_connection_name_here" -serverAddress "your_vpn_server_address_here"
-
- Configure SSH client
-
Download and install Bitvise SSH Client from here. (Or you can use any other SSH client you want.)
-
Run Bitvise SSH Client and input your server address and port and enjoy.
-
Optionally, you can create a scheduled task with below command to start Bitvise SSH Client with profile when log on to computer.
"C:\Program Files (x86)\Bitvise SSH Client\BvSsh.exe" -profile="your_bitvise_ssh_client_profile.bscp" -loginOnStartup
-