Multi server access through remote server using ssh

Team,

Presently I have 5 ip address kept in ip_abc1 file, for each of the ip address listed, i need to login on each ipaddress
one at a time and login as below for that specific ip address

ssh -p 8101 karaf@<ip.address_for the specific ip address as logged in>
password
 
features:list
osgi:list
shell:logout

In thisway i need to perform same steps for my other 4 ip address listed

Any suggession as i will be doing it from my remote jump boxes, to access these ip address.

I am trying to fit in the below code but not sure....

for ip_addr in $(cat ip_abc1);do
echo "###batch $ip_addr### begins"
ssh ${ip_addr} "bash -s" < input_file
echo "###batch $ip_addr### ends"
done

Regards
Whizkid

You can do something like this..

for ip_addr in $(cat ip_abc1); do
ssh ${ip_addr} <<EOD
<command>
<command>
EOD
done
1 Like

Also, you don't cram passwords into ssh, you use ssh keys.

1 Like

Hi blackrageous,

when i tried using your script provided by you.. as below

for ip_addr in $(cat ip_abc1); do
ssh ${ip_addr} <<EOD
ssh -p 8101 karaf@${ip_addr}
$pwd
features:list
EOD
done

It gives me the below error on my logs.

./<my_script>: line 26: karaf: command not found
Pseudo-terminal will not be allocated because stdin is not a terminal.

Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (password).
-bash: line 3: features:list: command not found

Note:Password is common on all the 5 ip address. it should auto input the password.

Kindly advise.

Hi Corona688,
Thanks for the auto-ssh password link.. between i have limited access to those hence i am unable to make any changes on those files mentioned..
The password here is generic for all the 5 ip address.

Thanks a ton blackrageous & Corona688

It worked out.