winfsp / sshfs-win

SSHFS For Windows
https://winfsp.dev
Other
5.15k stars 260 forks source link

SSHFS over jumphost fails #166

Open asbe opened 4 years ago

asbe commented 4 years ago

Hi, trying to set up sshfs over a jumphost. Have made sure the ssh.exe in the bin folder is first in path. SSH seems to read my global config, which works as expected using ssh. I get equivalent output if I try to use one of the configured hostnames from the config (where jumphost is explicitly stated using ProxyJump)

Seems similar issues are still open, is there a need for the /bin/sh it tries to call?

C:\Program Files\SSHFS-Win\bin
λ sshfs -o idmap=user -o ssh_command="/bin/ssh.exe -vvv -J jumphost.my.com -i /cygdrive/path/to/privkey" -osshfs_debug,LOGLEVEL=debug3 user@farside.my.com: x:
SSHFS version 3.5.2
executing </bin/ssh.exe> <-vvv> <-J> <jumphost.my.com> <-i> </cygdrive/path/to/privkey> <-x> <-a> <-oClearAllForwardings=yes> <-oLOGLEVEL=debug3> <-2> <user@farside.my.com> <-s> <sftp>
OpenSSH_8.0p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /cygdrive/path/to/config
debug1: Setting implicit ProxyCommand from ProxyJump: /bin/ssh -vvv -W '[%h]:%p' jumphost.my.com
debug1: Executing proxy command: exec /bin/ssh -vvv -W '[farside.my.com]:22' jumphost.my.com
debug1: identity file /cygdrive/path/to/privkey type -1
debug1: identity file /cygdrive/path/to/privkey-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
/bin/sh: No such file or directory
kex_exchange_identification: Connection closed by remote host
read: Connection reset by peer
jcsouplet commented 4 years ago

Hello

I have the same issue. Sssh connection through jumphost is working with ssh.exe (in cygwin) but not with the ssh.exe coming with SSHFS-Win. Is there any solution ?

ghost commented 3 years ago

same Problem

doivosevic commented 3 years ago

Same problem. Connecting to the jumphost works but jumping doesn't. Did any of you guys manage to work it out? @basti12203 @jcsouplet @asbe For me, regular ssh nameofserver works so it must be something with the specific ssh version used

doivosevic commented 3 years ago

@billziss-gh is this a supported scenario?

doivosevic commented 3 years ago

can I please get any answer on this? I'm more ok with this scenario not being supported than not getting any answer at all

Cuberick-Orion commented 3 years ago

Same issue - jumping failed.

The curious part is, debug info seems to show that it has succeeded (right before it got reset by peer)

debug1: Authentication succeeded (publickey).
Authenticated to redwood.gpu (via proxy).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: proc
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /home/username/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/username/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Sending subsystem: sftp
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2728, received 2960 bytes, in 0.2 seconds
Bytes per second: sent 11568.2, received 12552.0
debug1: Exit status 0
read: Connection reset by peer

I confirmed that using sshfs under wsl2 in command-line works (as in, it can jump). So it looks like an SSHFS-win problem. Any comments are appreciated.

fschiffers commented 3 years ago

Is there any solution for this ? Trying to use a jumphost while being on VPN. Have had no success so far

Rongronggg9 commented 2 years ago

A dirty solution:

  1. Download busybox-w32 and place it somewhere you like
  2. "Install" busybox to /path/to/SSHFS-Win/bin (run as administrator):
    .\busybox --install "C:/Program Files/SSHFS-Win/bin"

Only sh.exe is needed, you can delete other hard links. Alternatively, you may just create a hard link (/path/to/SSHFS-Win/bin/sh.exe -> /path/to/busybox.exe) manually instead of letting busybox do for you.

mrcblt commented 2 years ago

@Rongronggg9 Could you explain in more detail what the next steps are to map a network drive via SSHFS? I have done what you suggested, but it seems to have no effect when I afterwards try to do the mapping as indicated in the README.

Rongronggg9 commented 2 years ago

@Rongronggg9 Could you explain in more detail what the next steps are to map a network drive via SSHFS? I have done what you suggested, but it seems to have no effect when I afterwards try to do the mapping as indicated in the README.

@mrcblt It is impossible to map a network drive in the Explorer if you would like to use a proxy jump. You must mount the network drive by manually using sshfs.

Command (note that -o ssh_command=bin/ssh.exe is essential, unless /path/to/SSHFS-Win/bin is on top of your PATH):

sshfs [user@]host:[dir] mountpoint -o ssh_command=bin/ssh.exe [options]

To use a proxy jump, you may replace -o ssh_command=bin/ssh.exe with -o ssh_command="bin/ssh.exe -J [user@]host[:port]". But I recommend you to set a proxy jump in ~/.ssh/config:

Host jump
        Hostname jump.example.com
        User jump
        Port 1234

Host drive
        Hostname drive.example.com
        User drive
        Port 4321
        ProxyJump jump

Then mount it using sshfs:

sshfs drive:/path/to/mount Z: -o ssh_command=bin/ssh.exe
ElanHasson commented 2 years ago

@Rongronggg9 I have exactly that (just different user and hostnames. I get a reed: Connection reset by peer error.

Rongronggg9 commented 2 years ago

@ElanHasson Have you done this? https://github.com/winfsp/sshfs-win/issues/166#issuecomment-1013741113

Goddard commented 1 year ago

would be awesome to support this

BrianMarre commented 1 year ago

@Goddard just to mention it sshf-win can utilize jump hosts, the procedure is described here,

https://github.com/winfsp/sshfs-win/blob/0fd26684695513f8b6f46d70a941a2c97a9c3c82/README.md?plain=1#L141-L165

and works flawlessly for me

wsj-sjtu commented 1 year ago

@Rongronggg9 Could you explain in more detail what the next steps are to map a network drive via SSHFS? I have done what you suggested, but it seems to have no effect when I afterwards try to do the mapping as indicated in the README.

@mrcblt It is impossible to map a network drive in the Explorer if you would like to use a proxy jump. You must mount the network drive by manually using sshfs.

Command (note that -o ssh_command=bin/ssh.exe is essential, unless /path/to/SSHFS-Win/bin is on top of your PATH):

sshfs [user@]host:[dir] mountpoint -o ssh_command=bin/ssh.exe [options]

To use a proxy jump, you may replace -o ssh_command=bin/ssh.exe with -o ssh_command="bin/ssh.exe -J [user@]host[:port]". But I recommend you to set a proxy jump in ~/.ssh/config:

Host jump
        Hostname jump.example.com
        User jump
        Port 1234

Host drive
        Hostname drive.example.com
        User drive
        Port 4321
        ProxyJump jump

Then mount it using sshfs:

sshfs drive:/path/to/mount Z: -o ssh_command=bin/ssh.exe

Great solution!That works well for me.