-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathssh_multiple.py
More file actions
46 lines (36 loc) · 834 Bytes
/
ssh_multiple.py
File metadata and controls
46 lines (36 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from ssh_client import run_ssh_command
# LIST OF VMs
VMS = [
{
"host": "192.168.1.10",
"username": "root",
"password": "redhat"
},
{
"host": "192.168.1.11",
"username": "root",
"password": "redhat"
},
{
"host": "192.168.1.12",
"username": "root",
"password": "redhat"
}
]
COMMAND = "hostnamectl"
for vm in VMS:
result = run_ssh_command(
host=vm["host"],
username=vm["username"],
password=vm["password"],
command=COMMAND
)
print("=" * 60)
print(f"HOST: {result['host']}")
print(f"STATUS: {result['status']}")
if result["stdout"]:
print("\nSTDOUT:")
print(result["stdout"])
if result["stderr"]:
print("\nSTDERR:")
print(result["stderr"])