Running ssh on a remote system?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running ssh on a remote system?
# 1  
Old 09-12-2005
Running ssh on a remote system?

I need to install ypbind and yp-tools on over two-hundred remote client machines based on their redhat version. I have a centralized server on which I created an ssh public key. I then transfered the ssh public key to the authorized_keys file on all the remote hosts; therefore, I can login without being prompted for a password. However, my script is not working as expected. The script will copy the tarball with ypbind and yp-tools to the remote host, but it will not extract the tarball on the remote host. Is there a way of doing this with just one server side script or possibly ssh using a coprocess? Any help would be greatly appreciated. The following is a copy of my script:


#!/bin/bash
set -x
SERVERS=`cat list`
for MACHINE in $SERVERS
do
SYSREL=`/bin/ssh $MACHINE cat /etc/redhat-release`
if [ "$SYSREL" = "Red Hat Enterprise Linux AS release 3 (Taroon Update 3)" ]
then
/bin/scp ciscolinux_nis_package.tar $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf /tmp/ciscolinu_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.8-1.i386.rpm /tmp/ypbind-1.12-5.i386.rpm
elif [ $SYSREL = "Red Hat Linux release 9 (Shrike)" ]
then
/bin/scp redhat9_nis_package.tar $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf /tmp/redhat9_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.7-5.i386.rpm /tmp/ypbind-1.12-5.i386.rpm
elif [ $SYSREL = "Red Hat Linux release 8 (Shrike)" ]
then
/bin/scp redhat8_nis_package $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf redhat8_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.7-3.i386.rpm /tmp/ypbind-1.11-2.i386.rpm
elif [ $SYSREL = "Red Hat Linux release 7.3 (Valhalla)" ]
then
/bin/scp redhat7.3_nis_package.tar $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf /tmp/redhat7.3_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.6-4.i386.rpm /tmp/ypbind-1.10-7.i386.rpm
elif [ $SYSREL = "Red Hat Linux release 7.2 (Enigma)" ]
then
/bin/scp redhat7.2_nis_package.tar $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf /tmp/redhat7.2_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.5-1.i386.rpm /tmp/ypbind-1.8-1.i386.rpm
elif [ $SYSREL = "Red Hat Linux release 7.1sbe (Seawolf)" ]
then
/bin/scp redhat7.1_nis_package.tar $MACHINE:/tmp
/bin/ssh $MACHINE tar -xvf /tmp/redhat7.1_nis_package.tar
/bin/ssh $MACHINE rpm -ivh /tmp/yp-tools-2.4-7.i386.rpm /tmp/ypbind-1.7-8.i386.rpm
else
echo "Error install ypbind and yptools"
fi
done
# 2  
Old 09-12-2005
Try it with quotes...
/bin/ssh $MACHINE "tar -xvf redhat8_nis_package.tar"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

2. Shell Programming and Scripting

Running Commands on a Remote Linux Server over SSH

Hello, I'm trying to create a ksh script to ssh to a remote server, enter the password and a couple commands. For security reasons I have changed the login, password and ip in my example. #!/bin/ksh ssh -t -t username@12.5.5.3 << EOF password cd bin pwd EOF When I run it. It... (5 Replies)
Discussion started by: seekryts15
5 Replies

3. Shell Programming and Scripting

ssh - running remote command not exiting

Hi, i have a shellscript, where in i need to connect to different server start these three jobs and exit from the server and start the same three jobs on local server. ssh user@remotehost 'bash -s' << EOF ${GETT_HOME}/bin/start1 & sleep 10 ${GETT_HOME}/bin/start2 & sleep 10... (1 Reply)
Discussion started by: swapnabhargav
1 Replies

4. Shell Programming and Scripting

ssh sending local variable to remote system

I am running a useradd script, which works locally but I want to take some of that local information and send it to a remote system, ssh keys are set up between the two systems. I am attaching the script, look at the section titled "Sending information to FTP2" Removed attachment, added... (0 Replies)
Discussion started by: slufoot80
0 Replies

5. Solaris

how to login with ssh to remote system with out applying the remote root/usr password

how to login with ssh to remote system with out applying the remote root/user password with rlogin we can ujse .rhosts file but with ssh howits possible plz guide (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

6. Shell Programming and Scripting

Regarding ssh into remote system

How can i ssh into a remote system using ssh command in a shell script with password? I havent used password less authentication for the remote system. Thanks and Regards, Rupaa (4 Replies)
Discussion started by: Rupaa
4 Replies

7. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

8. Shell Programming and Scripting

Problem running ssh from remote server

So I have a script which performs some basic commands on another server via ssh. It works great, no issues at all. Let's call this "Script A" BUT, this working script is to be executed remotely from a different UNIX script on another server, also by ssh. Let's call this "Script B". When... (1 Reply)
Discussion started by: newerakb
1 Replies

9. Shell Programming and Scripting

Executing a script on a remote system via SSH

Hello all, I have a relatively simple script I wrote to generate a count of errors broken down. What I would like to do is execute this script from another server so that I don't actually have to log in to the server to run the check. The script on what we'll call "Server A" is: ... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

10. SuSE

ssh command on remote linux system hanging

Hi, Our systems: system1: amd 64 running suse linux 9 enterprize system2: amd 64 running esx vmware 3 with suse linux 9 enterprize. The problem is: when we ssh into system2 and execute the command: ls -al the session hangs. Infact session hangs when we execute any... (3 Replies)
Discussion started by: rajranibl
3 Replies
Login or Register to Ask a Question