Configuring WSL as a ControlMaster relay server

From Alliance Doc
Revision as of 17:30, 22 March 2024 by Pinto (talk | contribs)
Jump to navigation Jump to search

Disclaimer: This is still and experimental procedure (work in progress). Your feedback is welcome.

How to install Linux on Windows with WSL

  • Please follow this link for more detailed instructions

https://learn.microsoft.com/en-us/windows/wsl/install

  • this setup assumes the following:
* you selected Ubuntu as your distro of choice
* the hostname for the WSL instance is 'ubuntu' 
  edit /etc/hostname (ubuntu) and /etc/hosts (127.0.0.1 localhost ubuntu)
* the Windows system is named 'smart' and my login name is 'jaime'
* the user name on the ubuntu VM is also 'jaime'
* the Alliance user name is 'pinto' and I want to connect to 'cedar'

Install additional packages

sudo apt update && sudo apt upgrade -y
sudo apt install openssh-server -y

General ideal of the setup

[ssh client] ----> [ssh relay server] ----> [ssh target server]
your Windows     modified authorized_keys     target machine
  machine          in your Ubuntu VM           using cedar
  'smart'              'ubuntu'                  'cedar'

Login to the ubuntu VM and create a custom_ssh folder

jaime@ubuntu:~$ cat custom_ssh/sshd_config
Port 2222
HostKey /home/jaime/custom_ssh/ssh_host_ed25519_key
HostKey /home/jaime/custom_ssh/ssh_host_rsa_key
AuthorizedKeysFile /home/jaime/custom_ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM no
#UsePrivilegeSeparation no
Subsystem sftp /usr/lib/openssh/sftp-server
PidFile /home/jaime/custom_ssh/sshd.pid

NOTE: you may copy the ssh_host keys from /etc/ssh

Also customize .ssh/config file

jaime@ubuntu:~$ cat .ssh/config
Host cedar
    ControlPath ~/.ssh/cm-%r@%h:%p
    ControlMaster auto
    ControlPersist 10m
    HostName  cedar.computecanada.ca
    User pinto