Secure Shell Connection in Python
ssh connection
Section titled “ssh connection”from paramiko import clientssh = client.SSHClient() # create a new SSHClient objectssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #auto-accept unknown host keysssh.connect(hostname, username=username, port=port, password=password) #connect with a hoststdin, stdout, stderr = ssh.exec_command(command) # submit a command to sshprint stdout.channel.recv_exit_status() #tells the status 1 - job failedParameters
Section titled “Parameters”|Parameter|Usage |---|---|---|---|---|---|---|---|---|--- |hostname|This parameter tells the host to which the connection needs to be established |username|username required to access the host |port|host port |password|password for the account