LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Automatic ssh (https://www.linuxquestions.org/questions/linux-newbie-8/automatic-ssh-525161/)

venki 02-03-2007 01:01 AM

Automatic ssh
 
Hi all,

there are 50 systems..with ips 192.162.1.1 to 50..

each has given in dns as a station..

i.e station1 to station50..

now i want a shell script for ssh...that is

whn i execute commad..directely it shld ask password for that station..

say 1.sh

then it shld ask enter ur station number ..then if i give sation number it shld ask for password..

plz help me

acid_kewpie 02-03-2007 02:04 AM

Can you detail *why* you want this? it's probably a lot easier to work out how to achieve what you want if we know your end goal... from what you've explained, there seems to be nothing more than what ssh would directly give you anyway. i can't see anything "automatic" in this..

btw, should is spelt "should" not "shld", you aren't typing a txt msg...

itz2000 02-03-2007 05:16 AM

Code:

#!/bin/bash
function usage()
{
        echo $0 " login_name number_of_ssh port";
        echo $0 " my_login 3 22 --> will connect to 192.168.1.3 in port 22 with login : my_login"
}
if [ $# -ne 3 ]; then
        usage;
        exit 1;
fi
mask=`echo "192.168.1"`;
ssh -l $1 -p $3 $mask.$2;


acid_kewpie 02-03-2007 11:09 AM

well there was certainly no mention of port numbers anywhere in the question...

itz2000 02-03-2007 11:59 AM

Quote:

Originally Posted by acid_kewpie
well there was certainly no mention of port numbers anywhere in the question...

yeah... but why not give him a choice .. I made it anyway so why not give him more power with this script?!

acid_kewpie 02-03-2007 01:23 PM

i'm still lost as to how this is actively useful... you run "myscript 23" instead of "ssh station23" ?? how's that useful?

itz2000 02-03-2007 02:02 PM

Quote:

Originally Posted by acid_kewpie
i'm still lost as to how this is actively useful... you run "myscript 23" instead of "ssh station23" ?? how's that useful?

yes... I didn't understand why he wanted this script either.... but that's what he asked for, that's what he got.
Code:

for i in $(seq 1 50); do
echo "./first_post_script_name $i 23" > $i.sh;
chmod +x $i.sh;
done

this is the rest of the script....


All times are GMT -5. The time now is 07:48 PM.