Answers for "ssh python script"

1

python ssh library

#ssh client in python example
pip install paramiko

client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(server,port,username,password)
dir = directory
command = command
#change directory to the location of where you want to run the command and 
#change command to the command you want to execute
client.exec_command(f'cd {dir}; {command}')
client.close()
Posted by: Guest on March-05-2021
0

python how to run code in ssh

stdout = client.exec_command('python -c "exec(\"' + open('hello.py','r').read().encode('base64').strip('n') + '\".decode(\"base64\"))"' )[1]
Posted by: Guest on December-24-2020

Python Answers by Framework

Browse Popular Code Answers by Language