how to interact with Paramiko's interactive shell session?

前端 未结 2 1500
长情又很酷
长情又很酷 2020-12-06 04:08

I have some Paramiko code where I use the invoke_shell method to request an interactive ssh shell session on a remote server. Method is outlined here: invoke_shell()

相关标签:
2条回答
  • 2020-12-06 04:27

    I imported a file, interactive.py, found on Paramiko's GitHub. After importing it, I just had to change my code to this:

    try:
        import interactive
    except ImportError:
        from . import interactive
    
    ...
    ...
    
    channel.invoke_shell()
    interactive.interactive_shell(channel)
    sshClient.close()
    
    0 讨论(0)
  • 2020-12-06 04:28

    You can try disabling echo after invoking the remote shell:

    channel.invoke_shell()
    channel.send("stty -echo\n")
    
    while True:
        command = raw_input() # no need for `$ ' anymore
        ... ...
    
    0 讨论(0)
提交回复
热议问题