Sponsored Content
Top Forums Shell Programming and Scripting Ssh to an array of servers in a for loop Post 302852803 by Corona688 on Thursday 12th of September 2013 12:26:57 PM
Old 09-12-2013
A construct I often use:

Code:
ssh username@host exec sh -s -- "arg1" "arg2" "arg3" <<"EOF"

# Literal, unescaped script contents to be executed on the remote side.

echo "arg1 is $1"
echo "arg2 is $2"
echo "arg3 is $3"

# The EOF must be at the beginning of the line and not indented.
EOF

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

connecting servers using SSH - help needed

Hi all, I have a script written successfully and tuned by our members, now I am trying to execute this script from a taxi server. My aim is I want to connect to four servers via ssh where I want to ran a script or run some commands and write the output to a file in the Taxi server. I... (12 Replies)
Discussion started by: senthilkumar_ak
12 Replies

2. UNIX for Advanced & Expert Users

ssh: require passphrase from some servers but not others

We have a number of linux clusters running Oracle. The clusters require that all member nodes have promptless/passwordless login through ssh (ie. the keys were created with null passphrases). We also have a management server that is not a member of any cluster but routinely connects to nodes of all... (3 Replies)
Discussion started by: Squeakygoose
3 Replies

3. UNIX for Dummies Questions & Answers

SSH into multiple linux servers

Hi All, Okay, I need help. I need to ssh in to multiple linux servers execute certain commands and get them to email and print on the screen when the script is being executed. So below is my script. Its not working :-(. #!/bin/bash #linux/UNIX box with ssh key based login... (7 Replies)
Discussion started by: xytiz
7 Replies

4. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

5. IP Networking

Cant SSH Solaris servers

Hi all. Im working in a telco Environment and recently setup a new server. The other servers are a combination of Solaris + Linux machines. Using my new server , I can ping all other servers ( solaris + redhat linux ) but the issue lies where I try to ssh. I can only successfully ssh linux... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

6. Shell Programming and Scripting

Iterate array using loop over ssh

A simple script: #!/bin/bash test=test test1=(test1 test2 test3) echo ${test1 } ssh server 'echo '$test'; echo '${test1 }' ; echo '${test1}' ; for m in $(seq 1 $(echo '${test1 }' | tr " " "\n" | wc -l)); do echo $m ; echo '${test1}'; done'Here is the result: test1 test2 test3 testing... (5 Replies)
Discussion started by: mharald
5 Replies

7. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

8. UNIX for Dummies Questions & Answers

Ssh not working to one server from any of the servers

Hello, I tried ssh in debug mode and below is the debug snippet.ssh to a host is not working from any of the hosts No credentials cache found debug1: Miscellaneous failure No credentials cache found debug1: Next authentication method: publickey debug1: Offering RSA public key:... (7 Replies)
Discussion started by: Vishal_dba
7 Replies

9. UNIX for Beginners Questions & Answers

ssh multiple servers

Hi folks. I'm pretty new to unix, while I'm learning a lot I'm finding bash scripting quite confusing. Im sure it's not really, my head just hasn't clicked with it. Anyway, I need a script to loop the ip addresses stored in a file and run a "pgrep <process>" and return the pid or some... (2 Replies)
Discussion started by: MuntyScrunt
2 Replies

10. Shell Programming and Scripting

Find active SSH servers w/ ssh keys on LAN

Hi, I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step: #!/bin/bash # LAN SSH KEYS DISCOVERY SCRIPT </etc/passwd \ grep /bin/bash | cut -d: -f6 | sudo xargs -i -- sh -c ' && cat... (11 Replies)
Discussion started by: syrius
11 Replies
ltsp-update-sshkeys(8)					      System Manager's Manual					    ltsp-update-sshkeys(8)

NAME
ltsp-update-sshkeys - Update LTSP chroots to trust the server ssh keys SYNOPSIS
ltsp-update-sshkeys [OPTION] [host...] DESCRIPTION
If any hosts are specified, their SSH keys are exported in a file, by default /etc/ltsp/ssh_known_hosts.auto. Otherwise, all LTSP chroots are updated to trust the SSH keys of this server along with any additional keys in /etc/ltsp/ssh_known_hosts.* files. OPTIONS
-b --base Base of ltsp chroot. Default is /opt/ltsp if unspecified. -e --export File name to export the hosts SSH keys to (- for stdout). Default is /etc/ltsp/ssh_known_hosts.auto if unspecified. -h --help The application help page. -p --port SSH port for remote servers. -u --update Update the chroot SSH keys even if hosts are specified. SEE ALSO
ltsp-build-client(8), ltsp-update-kernels(8), ssh-keyscan(1), sshd(8). AVAILABILITY
ltsp-update-sshkeys is part of ltsp package and the latest versions are available in source form from https://launchpad.net/ltsp. MAN PAGE AUTHOR
Copyright 2012 Alkis Georgopoulos <alkisg@gmail.com>, distributed under the terms of the GNU General Public License version 2 or any later version. 2012-05-28 ltsp-update-sshkeys(8)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy