Python PXSSH GUI spawn on login failure

一曲冷凌霜 提交于 2020-01-04 14:03:10

问题


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.


回答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'


来源:https://stackoverflow.com/questions/20832740/python-pxssh-gui-spawn-on-login-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!