List of servers that are NOT authorized for password-less SSH

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List of servers that are NOT authorized for password-less SSH
# 1  
Old 02-17-2014
List of servers that are NOT authorized for password-less SSH

Hello friends,

We have around 500 servers (HPUX, AIX and linux) and all of them need to be accessed from our management box (linux) via password-less ssh.

Out of 500 around 150 servers are setup password-less. We need to setup password-less SSH for remaining servers. First we need to get the list of servers for which password-less SSH not working (around 350).

I tried keeping all the 500 servers names in a text file and ran ssh to every host in a loop but most of them are asking for password and it is lot of manual work to note them each box.

Is there any script which can generate list of servers for which password-les ssh not working without any manual intervention?

Pl advise, Thanks a lot,
# 2  
Old 02-18-2014
Something like this?

while read ip
  ssh -oNumberOfPasswordPrompts=0 $user@$ip 'echo' >/dev/null 2>&1
  [[ $? -ne 0 ]] && echo $ip >> no_ssh_server_list
done < server_list


Last edited by ahamed101; 02-18-2014 at 12:53 AM..
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 02-18-2014
im curious, after you get the list of hosts that haven't been set up with passwordless ssh, how would you go about actually setting it up, considering the number of hosts would be around '350', like you said?

are you going to log into each box?
# 4  
Old 02-18-2014

ssh-keygen # generate keys, if not already created

while read ip
  ssh-copy-id -i ~/.ssh/ $user@$ip >/dev/null 2>&1
  [[ $? -ne 0 ]] && echo 'Error: cannot copy key to '$user@$ip
done < no_ssh_server_list

Last edited by Scrutinizer; 02-18-2014 at 04:53 PM.. Reason: icode tags changed to code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Traverse through list of servers using ssh non-interactively.

I have 300 servers listed in servers.txt I motto is to check if my id "user1" has sudo privileges on the 3000 servers. I m using sudo -l to check if I have privileges or not. If wish to check this either non-interactively; if not; interactively. Below is the script I wrote: ... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. Shell Programming and Scripting

Find active SSH servers w/ ssh keys on LAN

Hi, I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step: #!/bin/bash # LAN SSH KEYS DISCOVERY SCRIPT </etc/passwd \ grep /bin/bash | cut -d: -f6 | sudo xargs -i -- sh -c ' && cat... (11 Replies)
Discussion started by: syrius
11 Replies

3. Red Hat

SSH password less setup asking for password

Hello Experts, when I am trying to connect my target server through sftp after creating ssh password less setup, it is asking for passowrd to connect. to setup this I followed below process: -->generated keys by executing the command "ssh-keygen -t rsa" -->this created my .ssh directory... (9 Replies)
Discussion started by: Devipriya Ch
9 Replies

4. Shell Programming and Scripting

A script to change password for all other servers

Hey Gurus, I have this requirement to change the password for other servers remotely from one server. So, I installed public keys on all servers and wrote the following script to do the job. Something appears to be wrong with my loop, as it only changes one server and ignores the rest. I'm... (24 Replies)
Discussion started by: Hiroshi
24 Replies

5. IP Networking

Cant SSH Solaris servers

Hi all. Im working in a telco Environment and recently setup a new server. The other servers are a combination of Solaris + Linux machines. Using my new server , I can ping all other servers ( solaris + redhat linux ) but the issue lies where I try to ssh. I can only successfully ssh linux... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

6. Shell Programming and Scripting

scp without password between two servers

Hello Folks, I have two linux server accounts server1 and server2 From the terminal if I say this command, scp /source/folder/from/server1/unix.txt Then it prompts for the password's password: I enter my password and then it... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

7. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

8. UNIX for Dummies Questions & Answers

Cannot ssh into machine although it has entry in authorized keys

We rebooted one our servers, call it server A, and now it cannot ssh into another machine, call it server B. We have the server A's ssh signature in server B's authorized key. I tried to manually generate the a new key using ssh-keygen command but the key looks nothing like the old key: It has... (10 Replies)
Discussion started by: mojoman
10 Replies

9. Shell Programming and Scripting

How to script to logon servers using id and password

Hey.. I am new in scripting.. I know a little bit of scripting.. I am facing some problem.. I need to create a script using which I may log on to a server (e.g. ftp) with ID and password.. thus copy a particular file to a local dir.. the commands required to do that I do know.. I am able to do it... (1 Reply)
Discussion started by: razeeev
1 Replies
Login or Register to Ask a Question

Featured Tech Videos