Skip to content

Commit 96286b5

Browse files
Create ssh-paramiko-1.py
1 parent b805724 commit 96286b5

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

ssh-paramiko-1.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import paramiko
2+
3+
hostname = "192.168.1.223"
4+
5+
username = "dba"
6+
7+
password = "dba"
8+
9+
commands = [
10+
"pwd",
11+
"id",
12+
"uname -a",
13+
"date"
14+
]
15+
16+
client = paramiko.SSHClient()
17+
18+
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
19+
20+
try:
21+
client.connect(hostname=hostname, username=username, password=password)
22+
except:
23+
print("[!] Cannot connect to the SSH Server")
24+
exit()
25+
26+
for command in commands:
27+
print("="*50, command, "="*50)
28+
stdin, stdout, stderr = client.exec_command(command)
29+
print(stdout.read().decode())
30+
err = stderr.read().decode()
31+
if err:
32+
print(err)

0 commit comments

Comments
 (0)