diff --git a/paraproxy/__init__.py b/paraproxy/__init__.py index 3e97a04..0d8eb2b 100644 --- a/paraproxy/__init__.py +++ b/paraproxy/__init__.py @@ -87,8 +87,10 @@ def __paramiko_SSHClient_proxy_cmdchain(self, hostname, rec=0): exe = os.path.basename(command_args[0].lower()) if exe.lower() == 'ssh' or exe.lower() == 'ssh.exe': # command is SSH, extract the host and the remote command - remote_cmd = command_args.pop() - remote_host = command_args.pop() + # Assume the first parameter is the remote host and the rest + # the commands we need to run on the host + remote_host = command_args[1] + remote_cmd = " ".join(command_args[2:]) chain = [(remote_host, remote_cmd.replace('%h', hostname).replace('%p', port))] next_hop = __paramiko_SSHClient_proxy_cmdchain(self, remote_host, rec+1)