Skip to Content
0
Former Member
May 13, 2008 at 03:15 PM

Giving Password to a ssh command in a script

60 Views

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