-
Notifications
You must be signed in to change notification settings - Fork 0
/
myfile
30 lines (24 loc) · 885 Bytes
/
myfile
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
#!/bin/bash
# File containing list of Linux servers (each server on a new line)
server_file="servers.txt"
# Replace 'your_root_password' with the actual root password
root_password="your_root_password"
# Check if the server file exists
if [ ! -f "$server_file" ]; then
echo "Server file '$server_file' not found."
exit 1
fi
# Read the server file line by line, handling spaces in filenames
while IFS= read -r server || [[ -n "$server" ]]; do
echo "Checking root login on $server..."
# Attempt to login
sshpass -p "$root_password" ssh -o StrictHostKeyChecking=no root@$server "echo 'Success'" > /dev/null 2>&1
# Check the exit status of the SSH command
if [ $? -eq 0 ]; then
echo "Root login on $server is successful."
else
echo "Root login on $server is not successful."
fi
done < "$server_file"
commit
edited by second server