WhitewaterFoundry / Pengwin

A Linux distro optimized for WSL based on Debian.
Other
1.47k stars 104 forks source link

Using fish shell breaks ssh ProxyJump #712

Open imgrant opened 2 years ago

imgrant commented 2 years ago

Describe the bug When fish is installed and configured as the default shell, ProxyJump in SSH does not work, that is, ssh -J user@jumphost user@destination host fails. SSH [to the jump host] without ProxyJump works, and if the user's [default] shell is, e.g. bash, then ProxyJump also works.

To Reproduce Steps to reproduce the behavior:

  1. Install fish shell using pengwin-setup, setting the default shell to fish
  2. Attempt to SSH to a host via an intermediary host using ProxyJump (-J):
user@mypc:~$ echo $SHELL
/usr/bin/fish
user@mypc:~$ ssh -J user@jumphost remoteuser@destinationhost
Bad packet length 1349676916.
ssh_dispatch_run_fatal: Connection to UNKNOWN port 65535: message authentication code incorrect
user@mypc:~$
  1. Note the error 'Bad packet length. Usingssh -vvvshows this happens at theSSH2_MSG_KEXINIT sent` step for the destination host.

Expected behavior The SSH command should succeed regardless of the user's shell.

Additional context The error is related to output in the shell initialisation script, see e.g. eval in config.fish breaks ssh proxy command. In particular, /etc/fish/conf.d/00-pengwin.fish seems to be the culprit (see additional troubleshooting below).

Basic Troubleshooting Checklist

[X] I have searched Google for the error message. [X] I have checked official WSL troubleshooting documentation: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#confirm-wsl-is-enabled. [X] I have searched the official Microsoft WSL issues page: https://github.com/Microsoft/WSL/issues. [X] I have searched the Pengwin issues page: https://github.com/WhitewaterFoundry/Pengwin/issues. [ ] I have run Windows 10 updates and restarted. [X] I have restarted WSL service: wsl.exe --terminate WLinux wsl.exe --shutdown.

What other troubleshooting have you attempted?

  1. Change the user's shell to bash (by setting the SHELL environment variable, but could also do via chsh and logging in and out):
user@mypc:~$ set -x SHELL "/bin/bash"
  1. Try the SSH again, observe that it works:
user@mypc:~$ echo $SHELL
/bin/bash
user@mypc:~$ ssh -J user@jumphost remoteuser@destinationhost
remoteuser@destinationhost's password:
remoteuser@destinationhost:~$
  1. Delete or otherwise disable the shell initialisation script that causes the issue:
user@mypc:~$ sudo mv /etc/fish/conf.d/00-pengwin.fish /etc/fish/conf.d/00-pengwin.fish.bak
  1. Change the user's shell back to fish:
user@mypc:~$ set -x SHELL "/usr/bin/fish"
  1. Try the SSH command again, observe that it works:
user@mypc:~$ echo $SHELL
/usr/bin/fish
user@mypc:~$ ssh -J user@jumphost remoteuser@destinationhost
remoteuser@destinationhost's password:
remoteuser@destinationhost:~$

Pengwin Version

21.9.0

WSL general info

WSL Version: 2
Locale: en_GB
Release Install Date: Tue Jun 29 19:10:56 BST 2021
Branch: co_release
Build: 22000
Full Build: 22000.1.amd64fre.co_release.210604-1628
Display Scaling: 1.25
Windows Theme: light
Windows Uptime: 0d 4h 6m
WSL Uptime: 0d 3h 21m
WSL Release: Pengwin
WSL Kernel: Linux 5.10.43.3-microsoft-standard-WSL2
Packages Count: 1599
imgrant commented 2 years ago

Further troubleshooting

The patch in WhitewaterFoundry/pengwin-base#119 fixes this by skipping the offending line in 00-pengwin.fish for non-login shells (which is the case for the ProxyJump step).

crramirez commented 2 years ago

Thank you for your contribution. I'll take the time to read the description and do some tests thoroughly.