Python PXSSH GUI spawn on login failure

I can't stop the GUI from spawning when a login failure occurs.

simple example that fails and spawns a GUI.

>>> import pxssh 
>>> 
>>> ssh = pxssh.pxssh()
>>> ssh.force_password = True
>>> ssh.login('127.0.0.1', 'root', 'falsePW')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pxssh.py", line 226, in login
    raise ExceptionPxssh ('password refused')
pxssh.ExceptionPxssh: password refused
>>> 

I have tried disabling x11 forwarding in these files, nothing changed.

/etc/ssh/ssh_config /etc/ssh/sshd_config

I have also tried going into the pxssh module and where it sets the ssh options I set the flag -x Disables X11 forwarding. still no change.

I am running cinnamon on Linux Mint, the pxssh docs said some x display managers will start up a GUI. To solve this is says to remove all ssh-agents, which I have also tried to no avail.

Asked By: Crispy
||

Answer #1:

After tampering with the pxssh.py module I found a solution thats very simple.

inside the pxssh.py module: sudo nano /usr/lib/python2.7/dist-packages/pxssh.py

Location Update: sudo nano /usr/lib/python2.7/dist-packages/pexpect/pxssh.py

class pxssh(spawn)

    def _init__( parameters )

        # change these variables to shown value
        self.force_password = True   
        self.auto_prompt_reset = False

    # next under the login function
    def login( parameters )
        # set the -x flag: disables x11 forwarding (removing GUI)
        ssh_options = '-q -x'
Answered By: Crispy
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

# More Articles