I’m trying to make changes to several computers at once in a private network. I have ssh keys setup so that I can ssh from the main computer to all the other computers without having to enter my password. So I wrote a bash script like
for computers in cat computer list
do
ssh $computers #type changes here
exit
done
but instead of executing the commands on every computer, it opens a shell on every computer for me to type into, just as if I had used ssh myself and not in a script. Can anyone tell me how to get this to work? I want to be able to add lines at the comment like “echo “test” > /testFile.txt” and be able to see the changes on each machine, in this case see testFile.txt on every machine.
I already tried that and it didn’t work. I tried it in a shell, and not a script, but I don’t think that should make a difference.
Although, when testing my ssh keys I did run ssh $computer ls -l ~/.ssh to make sure the key was working and that the permissions were right, but I did it individually and not in a script. So I’m not sure why I could list a folder but not make other changes.
Also, I’m doing this as root, so there shouldn’t be any permission problems.
You cannot do that on separate lines like that… this is going to behave
EXACTLY as if you were running the commands yourself. Put the commands
either in a script to be sent to the remote boxes and then called via ssh
(you can do scp and ssh calls using the keys you already have setup) or
make sure you’re doing something like this:
ssh $computers ‘your commands; go here’
Good luck.
On 05/17/2011 01:06 PM, blank888 wrote:
>
> I’m trying to make changes to several computers at once in a private
> network. I have ssh keys setup so that I can ssh from the main computer
> to all the other computers without having to enter my password. So I
> wrote a bash script like
> for computers in cat computer list
> do
> ssh $computers
> #type changes here
> exit
> done
>
> but instead of executing the commands on every computer, it opens a
> shell on every computer for me to type into, just as if I had used ssh
> myself and not in a script. Can anyone tell me how to get this to work?
> I want to be able to add lines at the comment like “echo “test” >
> /testFile.txt” and be able to see the changes on each machine, in this
> case see testFile.txt on every machine.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
On 05/17/2011 11:06 AM, blank888 wrote:
>
> I’m trying to make changes to several computers at once in a private
> network. I have ssh keys setup so that I can ssh from the main computer
> to all the other computers without having to enter my password. So I
> wrote a bash script like
> for computers in cat computer list
> do
> ssh $computers
> #type changes here
> exit
> done
>
> but instead of executing the commands on every computer, it opens a
> shell on every computer for me to type into, just as if I had used ssh
> myself and not in a script. Can anyone tell me how to get this to work?
> I want to be able to add lines at the comment like “echo “test”>
> /testFile.txt” and be able to see the changes on each machine, in this
> case see testFile.txt on every machine.