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

ssh-sk-helper.exe stops working in WSL2 if python is installed #2168

Closed
3 tasks done
juulSme opened this issue Oct 28, 2023 · 3 comments
Closed
3 tasks done

ssh-sk-helper.exe stops working in WSL2 if python is installed #2168

juulSme opened this issue Oct 28, 2023 · 3 comments

Comments

@juulSme
Copy link

juulSme commented Oct 28, 2023

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

I'm using a Yubikey-based FIDO2 ED25519 key (non-discoverable) with WSL2 to connect to an external host with SSH using the ssh-sk_helper.exe as explained in the Yubikey docs (export SSH_SK_HELPER="/mnt/c/Users/me/openssh/ssh-sk-helper.exe"). The WSL2 distro is Debian, the WSL openssh version is OpenSSH_9.2p1 Debian-2+deb12u1, OpenSSL 3.0.11 19 Sep 2023, the Windows openssh version of ssh-sk-helper.exe is the latest OpenSSH_for_Windows_9.4p1, LibreSSL 3.7.3. It works perfectly without having Python installed; I get a Windows prompt asking me to insert the key and touch it. However, when I install Python3, I no longer get the prompt, and the ssh command immediately crashes with obscure output:

me@wsl-debian:~ $ ssh uname@host
Confirm user presence for key ED25519-SK SHA256:PtCgHB6FeWfceiqL8+lSTyUZzVPL21JwlOIs99WmtS8
/mnt/c/Users/me/openssh/ssh-sk-helper.exe: 1: MZ����@��: not found
/mnt/c/Users/me/openssh/ssh-sk-helper.exe: 2: /mnt/c/Users/me/openssh/ssh-sk-helper.exe: 2: $�: not foundEq�m=t��Eq�3:��Eq�3:t�Eq�3:u�4Eq�3:r�.Eq�m=r�.Eq�m=u�6Eq��p��m=p�1Eq�&Ep��Dq��u�Eq��y�iEq�Ŏ�'Eq�&E��'Eq��s�'Eq�Rich&Eq�PEd�p�e�
                                                                                                                                                                                                                                                            %40g@�
                                                                                                                                                                                                                                                                  ��: not found

/mnt/c/Users/me/openssh/ssh-sk-helper.exe: 3: /mnt/c/Users/me/openssh/ssh-sk-helper.exe: 2: Eq�: not found
Syntax error: Unterminated quoted string
/mnt/c/Users/me/openssh/ssh-sk-helper.exe: 2: Eq�: not found
ssh_msg_recv: read header: Connection reset by peer
client_converse: receive: unexpected internal error
reap_helper: helper exited with non-zero exit status
sign_and_send_pubkey: signing failed for ED25519-SK "/home/me/.ssh/id_ed25519_sk_yubikey": unexpected internal error
uname@host: Permission denied (publickey).

I install Python using sudo apt-get install python3 python3-pip python-is-python3 python3-venv. Removing Python with sudo apt-get remove --purge python3 && sudo apt-get autoremove, followed by exiting the virtual machine and wsl --shutdown fixes the issue.

Expected behavior

I expect to be able to install Python without it effecting ssh-sk-helper.exe

Actual behavior

I can't.

Error details

No response

Environment data

PS C:\Users\me> $PsVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

# linux printenv
SHELL=/bin/bash
WSL2_GUI_APPS_ENABLED=1
WSL_DISTRO_NAME=Debian
WT_SESSION=a8060c0a-4e9f-4fb8-90f0-12be332e6e27
SSH_SK_HELPER=/mnt/c/Users/me/openssh/ssh-sk-helper.exe
SSH_AUTH_SOCK=/home/me/.ssh/ssh-agent.sock
NAME=wsl-debian
PWD=/home/me
LOGNAME=me
HOME=/home/me
LANG=en_US.UTF-8
WSL_INTEROP=/run/WSL/301_interop
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:
WAYLAND_DISPLAY=wayland-0
LESSCLOSE=/usr/bin/lesspipe %s %s
TERM=xterm-256color
LESSOPEN=| /usr/bin/lesspipe %s
USER=me
DISPLAY=:0
SHLVL=1
XDG_RUNTIME_DIR=/run/user/1000/
WSLENV=WT_SESSION:WT_PROFILE_ID:
KUBE_EDITOR=nano
PATH=/home/me/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Users/me/bin:/mnt/c/Program Files/WindowsApps/Microsoft.PowerShell_7.3.9.0_x64__8wekyb3d8bbwe:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Yubico/Yubico PIV Tool/bin:/mnt/c/Program Files/PuTTY/:/mnt/c/Users/me/bin:/mnt/c/Users/me/go/bin:/mnt/c/Users/me/openssh:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Programs/Git/cmd:~/projects/linux_config/bin:~/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HOSTTYPE=x86_64
PULSE_SERVER=unix:/mnt/wslg/PulseServer
WT_PROFILE_ID={574e775e-4f2a-5b96-ac1e-a2962a402336}
_=/usr/bin/printenv

Version

9,4

Visuals

No response

@maertendMSFT
Copy link
Collaborator

does this persist on a SSH session outside of WSL? The installed SSH in WSL is not Win32-OpenSSH, thus is considered out of scope for this repo.

@maertendMSFT maertendMSFT added the Waiting on Author Need more information to diagnose label Oct 30, 2023
@tfriedel
Copy link

tfriedel commented Nov 4, 2023

This fixed it for me:

  1. Create binformat config file

microsoft/WSL#8986 (comment)

in wsl create the file

sudo vim /usr/lib/binfmt.d/WSLInterop.conf 

with contents:

:WSLInterop:M::MZ::/init:PF
  1. restart binformat related systemd services

microsoft/WSL#8986 (comment)

restart systemd services

sudo systemctl restart systemd-binfmt
sudo systemctl restart binfmt-support
  1. install binformat systemd support

If you get an error on restarting, you might need to install binformat support first:

sudo apt update
sudo apt install binfmt-support
  1. check config

if you see

sudo ls -Fal /proc/sys/fs/binfmt_misc
total 0
drwxr-xr-x 2 root root 0 Mar 24 11:11 ./
dr-xr-xr-x 1 root root 0 Mar 24 11:11 ../
-rw-r--r-- 1 root root 0 Mar 24 11:35 WSLInterop
-rw-r--r-- 1 root root 0 Mar 24 11:35 jar
-rw-r--r-- 1 root root 0 Mar 24 11:35 python3.11
--w------- 1 root root 0 Mar 24 11:35 register
-rw-r--r-- 1 root root 0 Mar 24 11:35 status

sudo cat /proc/sys/fs/binfmt_misc/WSLInterop
enabled
interpreter /init
flags: PF
offset 0
magic 4d5a

everything should work fine also with systemd again.

from: https://www.reddit.com/r/bashonubuntuonwindows/comments/11vx61n/wsl2_error_cannot_execute_binary_file_exec_format/jdh2ovy/

@juulSme
Copy link
Author

juulSme commented Nov 6, 2023

Wonderful, thank you :)

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

No branches or pull requests

3 participants