cancel
Showing results for 
Search instead for 
Did you mean: 

Giving Password to a ssh command in a script

Former Member
0 Kudos

Hi

I wanna know how to give password to a ssh command in a script... that is my command iniside script is


q=`ssh 172.16.1.2 /usr/sbin/alternatives --config java </root/Desktop/2.txt 2>&1 | grep jdk1.6.0_05`

when i execute the script file and when this commands get executed it prompts for passord.. i dont want the script to wait for password from the terminal

i have also obtained the password as follows


#! /bin/sh
read ip
echo $ip
oldmodes=`stty -g`
stty -echo
read password
stty $oldmodes

i want to give this password which i obtained to the command so that it doesnt wait for a password at a terminal

Accepted Solutions (0)

Answers (1)

Answers (1)

markus_doehr2
Active Contributor
0 Kudos

I suggest you use ssh-keys without a password for this purpose:

http://www.linuxhelp.net/guides/ssh/

--> no need for a password.

Markus