Paramiko and exec_command - killing remote process?

前端 未结 8 1663
情书的邮戳
情书的邮戳 2020-12-09 05:09

I\'m using Paramiko to tail -f a file on a remote server.

Previously, we were running this via ssh -t, but that proved flaky, and the

8条回答
  •  难免孤独
    2020-12-09 05:17

    There is one way to do this. It works like on the shell

    ssh -t commandname
    

    The option -t is opening a pseudo pty to help ssh to track how long this process should last. the same can be done via pormiko via

    channel.get_pty()
    

    prior to execute_command(...). This will not open a shell like it does with channel.invoke_shell(), it just requests such a pseudo interface to tie all processes to. The effect can also be seen if ps aux is issued on the remote machine, the process is now attached to the sshd with a ptxXY interface.

提交回复
热议问题