Skip to content

Commit

Permalink
#2303 toggle agent forwarding using a paramiko command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 12, 2022
1 parent 4e1062c commit ff21776
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xpra/net/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from xpra.platform.paths import get_ssh_known_hosts_files
from xpra.platform.info import get_username
from xpra.scripts.config import parse_bool
from xpra.scripts.config import parse_bool, TRUE_OPTIONS
from xpra.scripts.pinentry_wrapper import input_pass, confirm
from xpra.net.bytestreams import SocketConnection, SOCKET_TIMEOUT, ConnectionClosedException
from xpra.make_thread import start_thread
Expand Down Expand Up @@ -344,7 +344,7 @@ def proxycommand_ended(proc):
chan = transport.open_channel("direct-tcpip", ("localhost", remote_port), ('localhost', 0))
log("direct channel to remote port %i : %s", remote_port, chan)
else:
chan = paramiko_run_remote_xpra(transport, proxy_command, remote_xpra, socket_dir, display_as_args)
chan = paramiko_run_remote_xpra(transport, proxy_command, remote_xpra, socket_dir, display_as_args, paramiko_config)
conn = SSHSocketConnection(chan, sock, sockname, peername, (host, port), socket_info)
conn.target = host_target_string("ssh", username, host, port, display)
conn.timeout = SOCKET_TIMEOUT
Expand Down Expand Up @@ -786,7 +786,8 @@ def chan_read(read_fn):
chan.close()
return out, err, code

def paramiko_run_remote_xpra(transport, xpra_proxy_command=None, remote_xpra=None, socket_dir=None, display_as_args=None):
def paramiko_run_remote_xpra(transport, xpra_proxy_command=None, remote_xpra=None,
socket_dir=None, display_as_args=None, paramiko_config=None):
from paramiko import SSHException
assert remote_xpra
log("will try to run xpra from: %s", remote_xpra)
Expand Down Expand Up @@ -850,7 +851,9 @@ def rtc(cmd):
log("open_session", exc_info=True)
raise InitExit(EXIT_SSH_FAILURE, "failed to open SSH session: %s" % e) from None
else:
if SSH_AGENT:
agent_option = str((paramiko_config or {}).get("agent", SSH_AGENT)) or "no"
log("paramiko agent_option=%s", agent_option)
if agent_option.lower() in TRUE_OPTIONS:
log.info("paramiko SSH agent forwarding enabled")
from paramiko.agent import AgentRequestHandler
AgentRequestHandler(chan)
Expand Down

0 comments on commit ff21776

Please sign in to comment.