diff --git a/README.md b/README.md index 2db8396..6b900ac 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ We recommend using Windows Terminal for the best experience: - Download the `.wsl` file from the [releases page](https://github.com/kaelemc/wsl-clab/releases/latest). - Double click the `.wsl` file to install. - Open 'Containerlab' from the start menu, or execute `wsl -d Containerlab` -- Complete the interactive shell selection. (if you plan to use [DevPod](#devpod), select `y` for SSH key copy). +- Complete the interactive shell selection. - If you have Docker Desktop installed. See [Docker Desktop](#docker-desktop). - Done! you can start labbing. (see [DevPod](#devpod) for a great way to lab). @@ -115,7 +115,7 @@ Windows version: 10.0.19044.5131 You will also be presented with the choice to have the Fira Code [nerd font](https://www.nerdfonts.com/font-downloads) automatically installed on your system. **We recommend you install this font (especially if using `zsh` as your shell of choice)**. - Finally you'll be asked if you want to copy your Windows SSH keys into WSL Containerlab, this is to enable passwordless SSH access. This is an integral step for [DevPod](#devpod) usage, while the default might be **not** to, we recommed you enter `y` (Yes). + Finally at the end SSH keys will be copied from your Windows host into Containerlab WSL to enable passwordless SSH. This is an integral step for [DevPod](#devpod) usage. If no SSH keys are found on your machine, an RSA keypair will be automatically generated. @@ -183,12 +183,7 @@ If you have Docker desktop installed. You **must** ensure the integration with t Check out [this video](https://www.youtube.com/watch?v=ceDrFx2K3jE) for more info. -Containerlab WSL was designed to support this lab experience out of the box. Just remember the following considerations. - -- At the Containerlab WSL setup prompt, make sure you select `Y` to copy your Windows SSH keys into WSL. If you don't have SSH keys, they will be automatically generated for you. - -> [!TIP] -> If you are already past setup, and have selected `N`, Don't worry. From inside Containerlab WSL execute `/etc/oobe.sh` and you can follow the interactive prompts again. It is not recommended to change your shell selection. +Containerlab WSL was designed to support this lab experience out of the box. Just remember the following consideration: - When using DevPod, ensure Containerlab WSL is started (it does **not** automatically launch on Windows startup), you should leave the terminal window with Containerlab WSL open in the background. diff --git a/images/devpod_settings.png b/images/devpod_settings.png index c8707c5..8151126 100644 Binary files a/images/devpod_settings.png and b/images/devpod_settings.png differ diff --git a/oobe.sh b/oobe.sh index 7365509..0e617c1 100644 --- a/oobe.sh +++ b/oobe.sh @@ -100,32 +100,27 @@ function import_ssh_keys { case $KEY_CHECK in rsa*) - echo -e "\033[32mRSA key found, Copying into Containerlab WSL...\033[0m" KEY=$(powershell.exe -NoProfile -Command 'Get-Content $env:userprofile\.ssh\id_rsa.pub') - echo $KEY >> /home/clab/.ssh/authorized_keys + echo $KEY | sudo tee -a /home/clab/.ssh/authorized_keys > /dev/null ;; ecdsa*) - echo -e "\033[32mECDSA key found, Copying into Containerlab WSL...\033[0m" KEY=$(powershell.exe -NoProfile -Command 'Get-Content $env:userprofile\.ssh\id_ecdsa.pub') - echo $KEY >> /home/clab/.ssh/authorized_keys + echo $KEY | sudo tee -a /home/clab/.ssh/authorized_keys > /dev/null ;; ed25519*) - echo -e "\033[32mED25519 key found, Copying into Containerlab WSL...\033[0m" KEY=$(powershell.exe -NoProfile -Command 'Get-Content $env:userprofile\.ssh\id_ed25519.pub') - echo $KEY >> /home/clab/.ssh/authorized_keys + echo $KEY | sudo tee -a /home/clab/.ssh/authorized_keys > /dev/null ;; False*) - echo -e "\033[34mNo host keys found, Generating RSA key...\033[0m" - powershell.exe -NoProfile -Command "ssh-keygen -t rsa -b 4096 -f \$env:userprofile\.ssh\id_rsa -N '\"\"'" + powershell.exe -NoProfile -Command "ssh-keygen -t rsa -b 4096 -f \$env:userprofile\.ssh\id_rsa -N '\"\"'" > /dev/null 2>&1 KEY=$(powershell.exe -NoProfile -Command 'Get-Content $env:userprofile\.ssh\id_rsa.pub') - echo $KEY >> /home/clab/.ssh/authorized_keys - # powershell.exe -NoProfile -Command "Get-Content $env:userprofile\.ssh\id_rsa.pub | ssh clab@localhost -p 2222 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'" + echo $KEY | sudo tee -a /home/clab/.ssh/authorized_keys > /dev/null ;; *) - echo "\033[34m\nCouldn't match key type, invoking Powershell may have failed. Create an issue at https://github.com/srl-labs/wsl-containerlab\033[0m" + echo "\033[34m\nSSH: Couldn't match key type, invoking Powershell may have failed. Create an issue at https://github.com/srl-labs/wsl-containerlab\033[0m" esac - echo -e "\033[32mKeys successfully copied. You can SSH into Container WSL passwordless with: 'ssh clab@localhost -p 2222'\033[0m" + echo -e "\033[32mSSH keys successfully copied. You can SSH into Container WSL passwordless with: 'ssh clab@localhost -p 2222'. (Ensure Containerlab WSL is open)\033[0m" } # We know the user clab exists from Dockerfile with UID 1000 @@ -208,11 +203,7 @@ Select zsh configuration: " esac done - read -p "Copy Windows SSH keys for passwordless SSH access? (y/N) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - import_ssh_keys - fi + import_ssh_keys exit 0 fi