tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.8k stars 182 forks source link

[Question] Interactive SSH #559

Closed pkulev closed 2 years ago

pkulev commented 2 years ago

Guys, cool package, can't enjoy enough!

Is there a way to do interactive SSH prompt like just ssh user@host, to let user type commands on remote host?

I want something like this:

./app.py stand shell --name dev3
Last login: Fri Sep 24 14:23:18 2021 from X.X.X.X
[centos@dev3 ~]$
pkulev commented 2 years ago

I eventually found out (https://github.com/tomerfiliba/plumbum/issues/565#issuecomment-960639043) about passing stdin, stdout and stderr and replaced subprocess.call(..., shell=True) with

ssh = plumbum.local["ssh"]["-tt", f"{stand.user}@{stand.hostname}"]
ssh("sudo su -",
    stdin=sys.stdin,
    stdout=sys.stdout,
    stderr=sys.stderr,
    retcode=None)

So leaving this for history.