summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRed_M <1468433+Red-M@users.noreply.github.com>2019-03-23 14:00:46 +1000
committerGitHub <noreply@github.com>2019-03-23 14:00:46 +1000
commit1b5ac750cf502d1aeaba561853d4ff110ed18456 (patch)
tree0ec2661e4f0d3b479f40644956b2faff619cf1e0
parent03168dd3cb57cbafebccef0d46e00c6bbd4bb0b9 (diff)
parent94548e70b7d9e4b9668003a6100a09b3d323375e (diff)
downloadpexpect-1b5ac750cf502d1aeaba561853d4ff110ed18456.tar.gz
Merge pull request #528 from tschmid/pxssh_customization
Allow customized pxssh client
-rw-r--r--pexpect/pxssh.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py
index 49d20cc..1dfa29a 100644
--- a/pexpect/pxssh.py
+++ b/pexpect/pxssh.py
@@ -259,7 +259,7 @@ class pxssh (spawn):
sync_multiplier=1, check_local_ip=True,
password_regex=r'(?i)(?:password:)|(?:passphrase for key)',
ssh_tunnels={}, spawn_local_ssh=True,
- sync_original_prompt=True, ssh_config=None):
+ sync_original_prompt=True, ssh_config=None, cmd='ssh'):
'''This logs the user into the given server.
It uses
@@ -303,6 +303,10 @@ class pxssh (spawn):
file to the client to handle itself. You may set any options you wish in here, however
doing so will require you to post extra information that you may not want to if you
run into issues.
+
+ Alter the ``cmd`` to change the ssh client used, or to prepend it with network
+ namespaces. For example ```cmd="ip netns exec vlan2 ssh"``` to execute the ssh in
+ network namespace named ```vlan```.
'''
session_regex_array = ["(?i)are you sure you want to continue connecting", original_prompt, password_regex, "(?i)permission denied", "(?i)terminal type", TIMEOUT]
@@ -354,7 +358,7 @@ class pxssh (spawn):
if spawn_local_ssh==False:
tunnel = quote(str(tunnel))
ssh_options = ssh_options + ' -' + cmd_type + ' ' + str(tunnel)
- cmd = "ssh %s -l %s %s" % (ssh_options, username, server)
+ cmd += " %s -l %s %s" % (ssh_options, username, server)
if self.debug_command_string:
return(cmd)