The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to connect unix server to unix server through shell scripts phatan Shell Programming and Scripting 2 06-19-2008 05:30 AM
Script runs fine on UNIX Server...Not through MSK Tool kit on Windows Server madhunk UNIX for Dummies Questions & Answers 5 01-31-2008 01:30 PM
How to share CGI Scripts across UNIX web server? karlsworld UNIX for Dummies Questions & Answers 5 02-06-2007 10:25 AM
How to share CGI Scripts across UNIX web server? karlsworld Shell Programming and Scripting 1 02-05-2007 09:32 PM
How to connect unix server via web max_san007 UNIX for Dummies Questions & Answers 3 11-17-2006 01:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2008
phatan
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
How to connect unix server to unix server through shell scripts

Hi,
I would like to connect UNIX server to UNIX server through shell scripts
and i have some concepts . But i am totally confused how to connect UNIX
server to UNIX server throuth running a script. It will be greatful to me if
any buddy will help me.

with simple example please.

Thanks in advance,
Phatn
Received Infraction
  #2 (permalink)  
Old 06-22-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

You'll need to elaborate on what you are trying to do (eg Run commands on another server? Transfer a file? Check the status of another server?) but the basis would be as follows:
Code:
#!/bin/sh
desthostname=<where you are connecting to>
destusername=<username you are connecting as>
commandtorun=<command to run on the destination server>
ssh $destusername@$desthostname $commandtorun
Then (on the destination server) create an authorized keys file (~/.ssh/authorized_keys) containing the public ssh key found in your source server's ~/.ssh/id_dsa.pub (or something similar) file.

This will allow passwordless connection between the two users on the two servers.

This all assumes you are using ssh of course and that you are trying to run a command on teh remote host. Fill in more details if this is not the case.
  #3 (permalink)  
Old 06-23-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Quote:
Originally Posted by Smiling Dragon View Post
You'll need to elaborate on what you are trying to do (eg Run commands on another server? Transfer a file? Check the status of another server?) but the basis would be as follows:
Code:
#!/bin/sh
desthostname=<where you are connecting to>
destusername=<username you are connecting as>
commandtorun=<command to run on the destination server>
ssh $destusername@$desthostname $commandtorun
Then (on the destination server) create an authorized keys file (~/.ssh/authorized_keys) containing the public ssh key found in your source server's ~/.ssh/id_dsa.pub (or something similar) file.

This will allow passwordless connection between the two users on the two servers.

This all assumes you are using ssh of course and that you are trying to run a command on teh remote host. Fill in more details if this is not the case.

if you would like to ssh from 1st server to 2nd server
1.Login into 2nd server using the 2ndserveruser and create a directory named .ssh (note . before ssh) under the home directory .
2. Login into 1st server and go to .ssh directory.
3. Run the following command from this directory
ssh-keygen -t rsa
This would prompt for the filename to which the key to be stored.A default value is given in brackets as id_rsa. So just press RETURN to continue. Next it would ask for Passphrase. Press RETURN to continue. Again it would ask for same passphrase again. Again press RETURN to continue.This would generate key pair and stores it in id_rsa file.
4.Exit from this .ssh directory (cd ..)and go back to home directory.From the home directory run the following command:
cat .ssh/id_rsa.pub|ssh 2ndserveruser@2ndserverIP 'cat >> .ssh/authorized_keys'
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0