SSH and SCP from windows with Python 3

I have been stuck here for several days. I want to copy a file from my windows to a remote linux server and run the script there. I have a tool for ssh and scp. from which I can call the linux server via the command line, but when I call it through python, it becomes hanged.

pro=subprocess.Popen('ssh user@server')
pro.communicate()

there is a blank screen. everything I type then appears on the screen. I was hoping there would be a password prompt, but no. I was thinking about using a library like paramiko, pexpect, pyssh, but none of them are supported in Python 3

Any help is appreciated.

+3
source share
2 answers

http://docs.fabfile.org/en/1.0.1/index.html

I'm not sure if it can be converted to 2to3

but it is pretty easy to use:

from fabric.api import run, env
from fabric.context_managers import hide
from fabric.colors import green

with hide('status', 'running', 'output'):
    print('Apache ' + env.host + ': ' + green(run('wget -q -O /dev/null http://localhost/ && echo OK')))

env.host , - , py3k

0

. netcat. 'man nc'. os.system() python, , .

netcat:

nc ( netcat) TCP UDP. TCP-, UDP-, TCP UDP, IPv4, IPv6. telnet (1), nc , telnet (1) .

:

  • TCP
  • shell- script HTTP-
  • SOCKS HTTP ProxyCommand ssh (1)
  • ,

, , , ( 'remote'). :

" ": , , O/S , O/S.

-1

All Articles