forum

Home / DeveloperSection / Forums / Subprocess on remote server

Subprocess on remote server

Anonymous User 1490 19-Nov-2015
I am using this code for executing command on remote server.

import subprocess
import sys
COMMAND="ls"
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],
                   shell=False,
                   stdout=subprocess.PIPE,
                   stderr=subprocess.PIPE)
result = ssh.stdout.readlines()
if result == []:
    error = ssh.stderr.readlines()
    print >>sys.stderr, "ERROR: %s" % error
else:
    print result
When I try to execute this script, I get prompt for password. Is there any way I could avoid it, for example, can I enter password in script somehow? Also, password should be encrypted somehow so that people who have access to the script cannot see it.

Updated on 19-Nov-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By