Step 1:
pip install paramiko
After the above installation, you can use the below sample script to connect Linux machine from Windows.
import paramiko
import sys
def etl_trigger(host,user,passw,cmd):
nbytes = 4096
hostname = host
port = 22
username = user
password = passw
command = cmd
try:
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname,port,username,password)
stdin,stdout,stderr=ssh.exec_command('ls -ltr')
outlines = stdout.readlines()
resp = ''.join(outlines)
# print(resp)
return True
except Exception as e:
print(e)
return False
hostname = 'server name'
username = username
password = password
command = 'unix command'
if __name__ == '__main__':
etl_trigger(hostname, username, password, command)
Please let us know if you guys face any issues.
Happy Coding !!!