I have over 200 servers, but is hard to keep tracking all of them by some documents, after a while it gets outdated, so to refresh this document, I have to know which servers I can login via SSH. I already create a script which gonna ping through a range of IP address, with this list now I would like to know if I can SSH into them. I was thinking in a combination of sshpass and ssh inside a loop, but wonder if that's the best solution.

Any idea or suggestion ?

  • 7
    This is why people use configuration management tools. Check puppet, chef, cfengine or any other. Use nmap -p 22 --open -sV if in a hurry (replace with an actual subnet). – dawud May 15 '13 at 13:43
  • I'm starting to use chef in our servers, but not all machines are on it right now, I'm putting them slowly, to avoid any complications. I didn't know this nmap command, I will look into it. – Valter Silva May 15 '13 at 14:17
  • What are these servers used for? I.e. what is the "master list" that must always get updated regardless of the state of other documents? DNS? /etc/ethers? dhcpd.conf? Or are all hosts simply on the same subnet? – ghoti May 15 '13 at 16:08
  • @ghoti, they're in different datacenters, so they don't have the same subnet. The document that I'm talking about it is a datasheet of excel, where I have all my server there. – Valter Silva May 15 '13 at 18:00

dawud's suggestion is good, you can also pass a list of servers to ssh-keyscan to scan them and log the server's public key.

  • I'm not sure if the OP is asking how to compile a list of servers running an sshd (in which case your answer works), or whether he's asking how to compile a list of servers that he personally can log in to, in which case it won't. – MadHatter May 15 '13 at 15:47
  • 1
    Me either. Not My Problem :) – MikeyB May 15 '13 at 16:40

Use some monitoring program like Nagios for this instead of writing your own scripts. It will alert you if some server goes down.

  • 1
    I'm not sure the OP is asking how to monitor, but simply if they have SSH access (regardless of the state of the machine). – TheCleaner May 15 '13 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.