script to monitor if ssh works.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users script to monitor if ssh works.
# 1  
Old 08-09-2010
script to monitor if ssh works.

Hi All,
I have a setup of around 100 servers with atleast 10 users on each box.The public key from one server has been created and updated on all other servers , so that passwordless login can be done from any use.


We recently had a problem that ssh keys on one of the system was changed and scripts using ssh failed.

I want to come up with a bash script to check if ssh is successful from one server to all servers using all users (All permutations and combinations)

Any ideas would be appreciated.
# 2  
Old 08-09-2010
To cover all combinations, you could try using two loops,

the outer one will loop through the servers available(list of host names) and inner one will loop through the users available in the current server.

And execute simple ssh command for the user@host_name combination and check if it returns success, if yes then ssh connectivity is ok. otherwise report the combination tried in error log.

some thing like ssh_test.sh, copy this script to all your server or may be in a shared file system that can be accessed by all servers.
Code:
    for TO in server_list
    do
       for USER in current_server_user_list
       do
            # try ssh  $USER@$TO /shared_filesystem/ssh_test.sh & - as background process, and wait for a while to return
            # if that doesn't return (it may wait for password as the public has been changed)
            # then kill that process and make log to stdout that 
            # $HOSTNAME -> $USER@$TO Failed
            # if that process returns make a success log to stdout
            # in this case we would be having the remote server script's stdout log in this process.
            # $HOSTNAME -> $USER@$TO Success
          done
    done

By this we can collect the log message that was created by remote server in a single server that has started this script first.

I am not sure whether this would work or not.

But this is what i would have tried.

All the best.
# 3  
Old 08-09-2010
Thanks! This is a good idea. I was also planning to use ssh -q so that everything happens in silent mode.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

PING to AIX works but TELNET FTP SSH doesn't work

root@PRD /> rsh DR KFAFH_DR: protocol failure due to unexpected closure from server end root@PRD /> telnet DR Trying... Connected to DR. Escape character is '^]'. Connection closed. root@PRD /> ftp DR Connected to KFAFH_DR. 421 Service not available, remote server has closed connection... (2 Replies)
Discussion started by: filosophizer
2 Replies

2. UNIX for Advanced & Expert Users

Cant ssh, but ping works

I cant ping to some of my machines, but ping works. I attach screenshots. Port is open and it is 22. I can't figure out why i cant access. https://www.unix.com/attachments/unix-for-advanced-and-expert-users/7492d1541541072-cant-ssh-but-ping-works-sshlisten-jpg... (17 Replies)
Discussion started by: tomislav91
17 Replies

3. Shell Programming and Scripting

SSh works but sftp doesn't for all users except root

I am sorry if i post in wrong Form. i have AIX server in which ssh works for all users but sftp only works for root user . it is too much important for me to solve this . Your help will be greatly appreciated. (1 Reply)
Discussion started by: khalid khanAIB
1 Replies

4. UNIX for Dummies Questions & Answers

Passwordless SSH works, scp does not

I know the "how to setup passwordless SSH" question is asked probably 5 times a week. I know how to setup passwordless SSH, it's not tough, however after reinstalling linux on my server, I found a problem. I could SSH into my server just fine, no password required, however SCP still required a... (4 Replies)
Discussion started by: corrado33
4 Replies

5. Solaris

SCP not working while SSH works

Dear expert, I have gone through the thread A similar error arising for me , please find the debug logs. I have tried from another server to push a file using scp but not working for me. i am using SunOS SUNW,SPARC-Enterprise machine. Thanks (5 Replies)
Discussion started by: posix
5 Replies

6. UNIX for Advanced & Expert Users

SSH key works from CMD line not script

OK , .. This is an odd one. I have a new server and I need to have a tunnel open to it. I have this exact process running on a few others but this new one I just got is not allowing the script to connect. I set up my users account and ssh keys from the server that will host the tunneling i... (6 Replies)
Discussion started by: jeffsandman0035
6 Replies

7. UNIX for Dummies Questions & Answers

$USER is not set in remsh but works fine via ssh login

1) ssh a@b echo $USER it display the correct value as a (even though i have not defined it in .profile) 2) remsh b -l a echo $USER it does not display the value as a (variable is not set any idea why $USER variable is not initialized when i login via remsh or rlogin but shows the... (10 Replies)
Discussion started by: reldb
10 Replies

8. AIX

scp not working while ssh works

I try to transfer a file from a Linux host to an AIX-host via scp, which fails. Logging into the AIX-system from the same Linux-system via ssh works well and i am a bit at a loss where to look. The original setup was with a user account provided via LDAP, but because of the error message (see... (4 Replies)
Discussion started by: bakunin
4 Replies

9. AIX

SSH login hangs, serial console works

Server, running AIX 6.1 developed strange problem when logging in via SSH -- ssh client hangs without any error. It is possible to run commands on server, using ssh ("ssh servername ls -l" is OK) It is possible to log in normally, using serial console connected to server. It was possible to... (2 Replies)
Discussion started by: ivar.zarans
2 Replies

10. UNIX for Advanced & Expert Users

How to monitor SSH sessions

Hi All Is it possible to log and monitor user activities in a SSH session. Is there any configuration or a patch to apply ?. Im currently using OpenSSH with AIX 5.3L and my syslog.conf includes auth.* /var/log/sshd/auth.log and in sshd_config it shows SysLogFacility AUTH... (4 Replies)
Discussion started by: Anuradhai4i
4 Replies
Login or Register to Ask a Question