Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az ssh config does not work in WSL2 #11224

Closed
1 of 2 tasks
jaypipes opened this issue Feb 28, 2024 · 2 comments
Closed
1 of 2 tasks

az ssh config does not work in WSL2 #11224

jaypipes opened this issue Feb 28, 2024 · 2 comments

Comments

@jaypipes
Copy link

Windows Version

Microsoft Windows [Version 10.0.22631.3155]

WSL Version

2.0.9.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.133.1-microsoft-standard-WSL2

Distro Version

Ubuntu 22.04.3 LTS

Other Software

PS C:\Users\jaypipes> ssh -V
OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3

PS C:\Users\jaypipes> wsl --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3155

jaypipes@winnie:~$ cat /proc/version
Linux version 5.15.133.1-microsoft-standard-WSL2 (root@1c602f52c2e4) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Thu Oct 5 21:02:42 UTC 2023

jaypipes@winnie:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Repro Steps

jaypipes@winnie:~$ cat demo.sh
#!/bin/bash

sub=<REDACTED>
sshconf=~/.ssh/demo
rg=<REDACTED>
vm=<REDACTED>

rm -rf "$sshconf"
az ssh config --file "$sshconf" --subscription "$sub" --resource-group "$rg" --name "$vm" --resource-type "Microsoft.HybridCompute/machines"
jaypipes@winnie:~$ ./demo.sh
\\wsl.localhost\Ubuntu-22.04\home\jaypipes\.ssh\az_ssh_config\<REDACTED>\id_rsa already exists.
Overwrite (y/n)? y
Unable to save public key to \\\\wsl.localhost\\Ubuntu-22.04\\home\\jaypipes\\.ssh\\az_ssh_config\\<REDACTED>\\id_rsa.pub: No such file or directory
Could not parse public key. Error: Incorrectly formatted public key. Key must be format '<algorithm> <base64_key>'

Expected Behavior

A colleague of mine did the exact same thing and got an SSH configuration file properly written to his $HOME/.ssh directory:

matt@DESKTOP-8UUMQBQ:~$ bash -x ~/bin/jump east setup
<REDACTED>
+ az ssh config --file /home/matt/.ssh/azjump --subscription <REDACTED> --resource-group <REDACTED> --name <REDACTED> --resource-type Microsoft.HybridCompute/machines
/home/matt/.ssh/az_ssh_config/<REDACTED>/id_rsa already exists.
Overwrite (y/n)? y
Generated relay information /home/matt/.ssh/az_ssh_config/<REDACTED>/<REDCATED>-relay_info is valid until 2024-02-28 05:31:44 PM in local time.
Generated SSH certificate /home/matt/.ssh/az_ssh_config/<REDACTED>/id_rsa.pub-aadcert.pub is valid until 2024-02-28 05:31:43 PM in local time.
/home/matt/.ssh/az_ssh_config/<REDACTED> contains sensitive information (id_rsa, id_rsa.pub, id_rsa.pub-aadcert.pub, <REDACTED>-relay_info). Please delete it once you no longer need this config file.

His WSL and OpenSSH (in both Ubuntu and Windows) were the exact same versions.

Actual Behavior

For some reason, unlike my colleague, my WSL environment wants to overwrite some \\\\wsl.localhost file path:

Unable to save public key to \\\\wsl.localhost\\Ubuntu-22.04\\home\\jaypipes\\.ssh\\az_ssh_config\\<REDACTED>\\id_rsa.pub: No such file or directory
Could not parse public key. Error: Incorrectly formatted public key. Key must be format '<algorithm> <base64_key>'

Diagnostic Logs

No response

Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jaypipes
Copy link
Author

The problem was that the azure-cli had been installed in Windows and WSL was executing that azure-cli Windows binary. I added the following to my .bashrc:

# Remove Windows paths from PATH...
export PATH=$(echo $PATH | sed -r 's/:\/mnt[^:]*//g')

and then manually installed azure-cli in WSL and the commands then succeeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant