ksh scripting, skip server if asks for password with SSH


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ksh scripting, skip server if asks for password with SSH
# 1  
Old 03-21-2012
ksh scripting, skip server if asks for password with SSH

Hi,
I am running a script that connets to a list of servers with SSH and runs a command but I have some servers that are asking for password (authorized keys is not configured properly).
Is there any way to do so that if I get a prompt for password just skip that entry?

my script:


Code:
#!/bin/ksh
for LINE in servers.txt
do
        ssh $LINE "some command"
done

# 2  
Old 03-21-2012
yes - add the ssh option to disable password authentication. man ssh_config. The options vary depending on the SSH implementation.

for openssh this should work
Code:
ssh -o PreferredAuthentications=publickey server foo

make sure to check the $? for failure.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh scripting SSH to Compare File Sizes

Hello, I currently have very little experience with Shell scripting and trying to create a script for the purpose of collecting the size of a couple sizes on 4 different Hosts. The Idea is to collected the information from the files in which the script is kicked off on, store the values into... (17 Replies)
Discussion started by: Abstract3000
17 Replies

2. Ubuntu

Run a script at remote server without ssh password

Hello, What I want to do is to run a file on remote server by running a script at localhost but script should not ask ssh password of my remote server when script is executed. Scenario1: To copy files from server2 to data server:$ scp -r root@server2_ip:/var/www/html/*.* /var/ When I enter... (6 Replies)
Discussion started by: baris35
6 Replies

3. AIX

How to ssh from an AIX OS server to a Fabric OS server without password?

Hi I'd like to ssh from an AIX OS server ( v5.3) to a Fabric OS server ( v6.1.2 ) without password. I tried using dsa or rsa keys but it didn't work, the aix server still asked for the password. Somebody help, please :(:(:( (8 Replies)
Discussion started by: bobochacha29
8 Replies

4. Cybersecurity

Password less SSH login to different server

Hi, It is continuation with my other thread, The issue i found is U1 does not set properly for password less ssh. for setting up password less ssh i followed the following steps 1. ssh-keygen 2. ssh-copy-id -i ~/.ssh/id_rsa.pub hostname 3. /usr/bin/ssh -t -t U1@hostname sample.sh ... (3 Replies)
Discussion started by: sakthi.99it
3 Replies

5. Shell Programming and Scripting

ksh script with Interactive ssh on remote server

HI Unix Gurus, I an stuck in an interesting issue, where I am trying to execute a script on remote server after ssh. The script on remote server is interactive,. Whenever it is called it hangs where it expects input from terminal and I have to terminate it. I have searched through fourm... (12 Replies)
Discussion started by: Jeevanm
12 Replies

6. Shell Programming and Scripting

[SSH] Need to connect to remote server as different user and without password

I have a task requiring that USER_A run a script, which connects to HOST_B as USER_B and does not ask for a password. If I am logged in on HOST_A as USER_B, I can connect to HOST_B without a password, no problem. However, if I try running ssh with the command line "ssh USER_B@HOST_B" while... (3 Replies)
Discussion started by: Totengraber
3 Replies

7. OS X (Apple)

OSX asks password but i don't use a password!!

When i try to install some software OSX asks for a password but i don't use a password at all. Somebody knows a answer please??? asta (4 Replies)
Discussion started by: astapopulos
4 Replies

8. Solaris

Solaris 8 - Asks for current root password when trying to change root password.

Hello All, I have several solaris boxes running Solaris 8. When changing root passwords on them, all will simply ask for the new root password to change and of course to re-type the new password. One of the systems however asks for the existing root password before it will display the new password... (8 Replies)
Discussion started by: tferrazz
8 Replies

9. Shell Programming and Scripting

automatic ssh into remote server using ksh

I still have to enter the password when I want to auto login w/o having to do any command line entry. This code works but I don't want to have to enter the password at the command line. After manning ssh I still am not sure what settings I need to change. Please help. Thanks! <<<output>>>... (4 Replies)
Discussion started by: tekline
4 Replies

10. Solaris

network config problem - how to set the server for others to ssh without password

Hi, I want to ssh the linux server without inputting the password, how can I config this server? Thanks in advance! (1 Reply)
Discussion started by: GCTEII
1 Replies
Login or Register to Ask a Question