Skip to content

Commit

Permalink
Merge pull request #528 from tschmid/pxssh_customization
Browse files Browse the repository at this point in the history
Allow customized pxssh client
  • Loading branch information
Red-M committed Mar 23, 2019
2 parents 03168dd + 94548e7 commit 1b5ac75
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pexpect/pxssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def login (self, server, username, password='', terminal_type='ansi',
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
Expand Down Expand Up @@ -303,6 +303,10 @@ def login (self, server, username, password='', terminal_type='ansi',
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]
Expand Down Expand Up @@ -354,7 +358,7 @@ def login (self, server, username, password='', terminal_type='ansi',
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)

Expand Down

0 comments on commit 1b5ac75

Please sign in to comment.