How can I make an SSH connection in Python 3.0? I want to save a file on a remote computer where I have password-less SSH set up.
First:
Two steps to login via ssh without password
in your terminal
[macm@macm ~]$ ssh-keygen
[macm@macm ~]$ ssh-copy-id -i $HOME/.ssh/id_rsa.pub root@192.168.1.XX <== change
Now with python
from subprocess import PIPE, Popen
cmd = 'uname -a'
stream = Popen(['ssh', 'root@192.168.1.XX', cmd],
stdin=PIPE, stdout=PIPE)
rsp = stream.stdout.read().decode('utf-8')
print(rsp)