connecting servers using shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting connecting servers using shell script
# 1  
Old 08-30-2011
connecting servers using shell script

Hi ,
I have three linux servers. I want to login from one server and check some status in the other server.

How to connect other server from one server using shell script.
Can anyone advice on this?

# 2  
Old 08-30-2011
$ ssh user@hostname "command_to_run_on_remote_host"

ssh - Linux Command - Unix Command
# 3  
Old 08-30-2011
1. Generate ssh keys on client side (host from which You'll run script).
mkdir .ssh && chmod 700 .ssh

Leave all in defaults (hit enter, enter, enter...), don't enter any passphrase.
2. Copy file to remote server (repeat for all servers You want to use).
scp ~/.ssh/

3. Login on remote host and add key to your authorized_keys:
mkdir .ssh && chmod 700 .ssh     #ignore errors if occure here
cat >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys

4. Logout from remote server
5. Try logging to remote server again, should work without asking for pass:

In script use:
ssh "uptime"

This will execute "uptime" on remote host and return all STDOUT to local console.
# 4  
Old 08-30-2011
Hi All,
I need to single script to connect the server and check one particular script is running or not. I want in shell script maode.

If i run the script, it will connect two or three servers and get back with the status of the server's script.

Thanks in advance
# 5  
Old 08-30-2011
What did you try so far, where are you stuck? This is a support forum, not a freelancer/project forum.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for connecting multiple servers and then copying 30 days old files

Shell script for connecting multiple servers and then copying 30 days old files from those server . HI , I have 6 multiple servers pla1,pla2,pla3,pla4,pla5,pla6 1. These six servers have common shared mount point /var/share 2. Running script from /var/share to connect these servers.I... (1 Reply)
Discussion started by: rcroyal88
1 Replies

2. UNIX for Dummies Questions & Answers

shell script for connecting to a different user

Hi Gurus, I want to connect to a different user in unix from my terminal. I know the password of that user and username.when i am using "su username" it asks me for the password and entering the corresponding password ,it takes me to that.but i want to write a shell script in which i will be... (4 Replies)
Discussion started by: sanjay.login
4 Replies

3. Shell Programming and Scripting

Connecting to oracle database from shell script

Hi all, I am satyakiran , i am new to the forum. i never done shell scripts for connecting to the data base (oracle) and fetching the data from the database( thru sql select statements ) i want to know 1. how to connect to the data base(oracle) using shell script 2. how to retrieve data... (8 Replies)
Discussion started by: satyakiran
8 Replies

4. 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

5. Shell Programming and Scripting

Connecting to sybase via shell script.

Hi All, I was able to connect to sybase in shell script and also able to run few sql queries, something like this, #!/usr/bin/ksh -x temp=`echo "select name from sysobjects where type = 'U'"` results=`isql -SDS_SERVER-UAdhocUser -Pha12 <<EOF set rowcount 6 $temp go EOF` line_count=0... (1 Reply)
Discussion started by: arvindcgi
1 Replies

6. Shell Programming and Scripting

error connecting sql through a shell script

Hi I am getting this error while connecting to sql through a shell script, whereas i am able to connect to sql directly. It was working properly earlier, no clue why i am getting this. Please find the log below: FTP to <IP> completed Wed Apr 30 11:42:01 BST 2008 Program ended. Wed Apr 30... (1 Reply)
Discussion started by: nehak
1 Replies

7. UNIX for Advanced & Expert Users

connecting servers

hi everyone i want to establish smtp connection between unix server and windows 2k3 mail server they are on one intranet. and unix server has ftp and telnet connection with the mail server. . (0 Replies)
Discussion started by: parmeet
0 Replies

8. UNIX for Dummies Questions & Answers

connecting servers

Please help me out i want to know how to send email from unix machine to any email-id. mail to be sent is web based mail. (1 Reply)
Discussion started by: parmeet
1 Replies

9. Shell Programming and Scripting

Connecting to remote servers

Please advise, The previous thread asked about the automated transfer of files between two servers. The question is - is there any way of encrypting the password within the script or is it a matter of setting the permissions settings on the script so that it can only be executed and possibly... (1 Reply)
Discussion started by: rdbooth
1 Replies

10. UNIX for Advanced & Expert Users

Connecting DB in the Shell Script to do SQL Query

Any link or example to write shell script for the Connecting Oracle for Quering through SQL thanks in advance ... Cheers !! Mehul Doshi (3 Replies)
Discussion started by: mehuldoshi
3 Replies
Login or Register to Ask a Question