Question:
I am trying to run a Python script remotely on my RPi from another python script on my computer.
For now, I have created a local network on my RPi, that my computer can connect to.
I tried to run a subprocess connecting through ssh from my computer:
import subprocess
proc = subprocess.call(["ssh","pi@192.168.4.1","python3 /home/pi/desktop/python_server/python_server.py"],stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
if not line:
break
print("test:", line.rstrip())
But the script doesn't start and I dont get any data back.
How can I connect remotely to the RPi from my computer and start the Python script?
If possible it would be best if this to be done without manually connecting to a local network first. But I dont know if this is possible?
Update:
The process got stuck as it was waiting for me to enter the password to the PI.
How can I avoid entering a password or can Python automatically enter a password to access ssh?
NOTE: I would like to access through ssh from any device, so a ssh key between a single computer and the RPi is not an option.
ssh
command would't do anything on the remote - did you test FIRST before you tried to script it? – Milliways Dec 02 '20 at 11:16