mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
334d87251e
This is a small wrapper on 'sshfs' which allows it to use Plink as its transport. Mostly useful for when I've already got a PuTTY session open to a given host with connection sharing enabled, and want to tunnel over that rather than painstakingly re-establishing a separate connection.
42 lines
1.1 KiB
Python
Executable File
42 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Wrapper around the FUSE 'sshfs' client, which arranges to use Plink
|
|
# as the SSH transport subcommand.
|
|
#
|
|
# This is not totally trivial because sshfs assumes slightly more of
|
|
# OpenSSH's command-line syntax than Plink supports. So we actually
|
|
# give sshfs a subcommand which is this script itself, re-invoked with
|
|
# the --helper option.
|
|
|
|
import sys
|
|
import os
|
|
import shlex
|
|
|
|
if sys.argv[1:2] == ["--helper"]:
|
|
# Helper mode. Strip OpenSSH-specific '-o' options from the
|
|
# command line, and invoke Plink.
|
|
plink_command = ["plink"]
|
|
|
|
it = iter(sys.argv)
|
|
next(it) # discard command name
|
|
next(it) # discard --helper
|
|
|
|
for arg in it:
|
|
if arg == "-o":
|
|
next(it) # discard -o option
|
|
elif arg.startswith("-o"):
|
|
pass
|
|
else:
|
|
plink_command.append(arg)
|
|
|
|
os.execvp(plink_command[0], plink_command)
|
|
|
|
else:
|
|
# Normal mode, invoked by the user.
|
|
sshfs_command = [
|
|
"sshfs", "-o", "ssh_command={} --helper".format(
|
|
os.path.realpath(__file__))
|
|
] + sys.argv[1:]
|
|
|
|
os.execvp(sshfs_command[0], sshfs_command)
|