Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python ssh connection

import pxssh
s = pxssh.pxssh()
if not s.login ('localhost', 'myusername', 'mypassword'):
    print "SSH session failed on login."
    print str(s)
else:
    print "SSH session login successful"
    s.sendline ('mycommand')
    s.prompt()         # match the prompt
    print s.before     # print everything before the prompt.
    s.logout()
    
#We can also execute multiple command like this:
s.sendline ('uptime;df -h')
Comment

python ssh into server

import paramiko

host = "YOUR_IP_ADDRESS"
username = "YOUR_LIMITED_USER_ACCOUNT"
password = "YOUR_PASSWORD"

client = paramiko.client.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host, username=username, password=password)
_stdin, _stdout,_stderr = client.exec_command("df")
print(stdout.read().decode())
client.close()
Comment

PREVIOUS NEXT
Code Example
Python :: python date from string 
Python :: pandas reset index without adding column 
Python :: mongodb aggregate count 
Python :: Simple pagination wrapper for discord.py. 
Python :: dict itterator python recursive 
Python :: turn off xticks matplotlib 
Python :: numpy normalize 
Python :: python time wait 
Python :: runge kutta 
Python :: Filter pandas DataFrame by substring criteria 
Python :: pause python 
Python :: remove spaces from string python 
Python :: enumerate vs zip python same time 
Python :: datetime.datetime.fromtimestamp() 
Python :: import sklearn.metrics from plot_confusion_matrix 
Python :: normal distribution in python 
Python :: python path from string 
Python :: conda import django 
Python :: change variable type python 
Python :: add column array python 
Python :: add time to datetime python 
Python :: python strptime format codes 
Python :: pylint import error 
Python :: create or update django models 
Python :: python reverse words in string 
Python :: when was python created 
Python :: python convert string datetime into datetime 
Python :: pandas df make set index column 
Python :: convert numpy array to tensor 
Python :: creating a virtual environment with django on windows 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =