We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b805724 commit 96286b5Copy full SHA for 96286b5
1 file changed
ssh-paramiko-1.py
@@ -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