简体   繁体   中英

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM