0

I'm trying to restart my core service through Python. This is my code:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='123.456.789.876', username='username', password='password', key_filename='/path/to/.ssh/id_rsa')
print ssh.Popen("service core restart", shell=True, stdout=ssh.PIPE).stdout.read()

When I run it I get AttributeError: 'SSHClient' object has no attribute 'Popen'. What am I doing wrong?

0

2 Answers 2

3

SSHClient from paramiko does not contain any Popen method. See documentation for the module here: http://docs.paramiko.org/en/2.4/api/client.html

Maybe you want exec_command or invoke_shell?

2

It's exactly what the error message says: You're trying to call a method (Popen) that doesn't exist in the SSHClient class

Not the answer you're looking for? Browse other questions tagged or ask your own question.