Sponsored Content
Top Forums Shell Programming and Scripting Passing password in script for ssh connection - no except Post 302541158 by sapadmin on Friday 22nd of July 2011 03:55:55 PM
Old 07-22-2011
Passing password in script for ssh connection - no except

Used the script posted on forum - unix.com/shell-programming-scripting/21597-script-change-passwords-same-user-multiple-servers.html but the last question posted on this seems to be still unanswered, tried different things with no success, can someone help giving an way to pass the password via script for ssh connection. Using except is not an option. We have more than 300 servers and need to setup an script to change password. Also setting up ssh public keys for password less communciation is not an option with these limitation, I am using following code, but it just waits on the password prompt. can someone help?
Code:
#! /usr/bin/ksh
DELAY=4
stty -echo
print -n Enter Old Password-
read OLDPASS
print
print -n Enter New Password-
read NEWPASS
print
stty echo
USER=$(whoami)
exec 4>&1
prog=${0##*/}
progdir=$(dirname $0)
for HOST in $( cat "$progdir/.servers" ) ; do
     ssh -T -oPreferredAuthentications=password $HOST >&4 2>&4 |&
     sleep $DELAYprint -p $OLDPASS
     sleep $DELAY
     print -p touch changepassdatafile.$HOST
     sleep $DELAY
     print -p exit
     wait
done

sapadmin

Last edited by radoulov; 07-22-2011 at 05:48 PM.. Reason: Code tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing password in shell script

Hi, Anybody help to write a shell script as below requirement. script stops some costomized application services. 1. first it will stop apache as root 2. then it will switch to my application user and stop app service. Note: passing password is required to stop app service as app... (1 Reply)
Discussion started by: manojbarot1
1 Replies

2. Shell Programming and Scripting

ssh - passing password in shell script

I have a requirement, I need to run a command at remote system using a ssh. Is there any way we can pass the username and password in shell script to the ssh command as we did it in one of the shell script for FTP. ftp -n $i <<!EOF >> user Username $PASSWD cd /home/scripts ... (5 Replies)
Discussion started by: Muktesh
5 Replies

3. Cybersecurity

ssh connection without password

The subject has been outlined in many articles, yet I can not establish a password-less ssh connection. Below I show what I did and then I include ssh debug info, maybe someone would be able to point out something I am not doing right. My setup: two SCO 5.0.7 boxes on a private lan, user... (6 Replies)
Discussion started by: migurus
6 Replies

4. Shell Programming and Scripting

SSH Login by passing password.

ssh/sftp login by passing password , is it possible.Don't want to expect. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

5. Shell Programming and Scripting

Password less connection(sftp/ssh)

Dear All, I'm trying to configure a passwordless connection between two servers of HP-UX. i have srearched the configuration in google so many times and as per the guidence i have done all the steps, but still its not working and every time it is asking for password while trying to scp some file... (2 Replies)
Discussion started by: panknil
2 Replies

6. Shell Programming and Scripting

Passing Password to SSH without using expect in a Script

How can I pass password in SSH command without using expect in a shell program. I don't have expect installed on my Solaris server. #!/bin/bash ssh user@hotname (how to supply pass in script?:wall:) Experts please help its very urgent. Shrawan Kumar Sahu (4 Replies)
Discussion started by: ss135r
4 Replies

7. Shell Programming and Scripting

Passing password for ssh in Script

I want to do following 2 commands via script: 1) eval `ssh-agent`2) ssh-add /export/home/sufuser/.ssh/id_rsa When asked for passphrase enter "passwordpassword1234 but whenever I run the script it stucks after "ssh-add /export/home/sufuser/.ssh/id_rsa" command and asks fro... (4 Replies)
Discussion started by: yogeshpawar
4 Replies

8. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

9. Shell Programming and Scripting

Passing special characters in an SSH connection

I have a script like this #!/bin/bash hello=$1 echo `hostname` $hello ssh gtint16 "echo $hello" if I run this as #script.sh "hello''", it prints only hello on that ssh session and not the single quotes, but locally its printing hello''. I want the single quotes also to be printed... (2 Replies)
Discussion started by: Tuxidow
2 Replies

10. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies
DELAY(9r)																 DELAY(9r)

NAME
DELAY - General: Delays the calling routine a specified number of microseconds SYNOPSIS
void DELAY( int Specifies n ); ARGUMENTS
Specifies the number of microseconds for the calling process to spin. DESCRIPTION
The DELAY routine delays the calling routine a specified number of microseconds. DELAY spins, waiting for the specified number of microseconds to pass before continuing execution. For example, the following code results in a 10000-microsecond (10-millisecond) delay: . . . DELAY(10000); . . . The range of delays is system dependent, due to its relation to the granularity of the system clock. The system defines the number of clock ticks per second in the hz variable. Specifying any value smaller than 1 Hz to the DELAY routine results in an unpredictable delay. For any delay value, the actual delay may vary by plus or minus one clock tick. Using the DELAY routine is discouraged because the processor will be consumed for the specified time interval and therefore is unavailable to service other processes. In cases where kernel modules need timing mechanisms, you should use the sleep and timeout routines instead of the DELAY routine. The most common usage of the DELAY routine is in the system boot path. Using DELAY in the boot path is often acceptable because there are no other processes in contention for the processor. RETURN VALUES
None SEE ALSO
Routines: sleep(9r), timeout(9r) DELAY(9r)
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy