I am new to Python and wanted to know how to best handle this situation. I am currently trying to run a series of commands on remote Linux servers. Each server has one user and a root user on them. I am currently using Fabric to automate this task, but I am getting unexpected behavior.
I have tried the following:
import from fabric import *
connect_kwargs = {'key_filename': r'C:pathtokey'}
conn = Connection('X.X.X.X', user = 'user1', connect_kwargs = connect_kwargs)
conn.run("hostname", pty=True,warn=True)
returns the proper hostname
Conversely,
running
connect_kwargs = {'key_filename': r'C:pathtokey}
conn = Connection('X.X.X.X', user = 'root_user', connect_kwargs = connect_kwargs)
conn.run("hostname", pty=True,warn=True)
returns an interactive shell waiting for user input. I have found a workaround using Responders, but it seems as if this is more of a patchwork solution as opposed to a complete one. I would appreciate any input. Thanks.
Questmeyer14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.