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
what is meaning of exit(0) and exit(1) amitpansuria UNIX for Dummies Questions & Answers 1 08-28-2007 03:02 AM
exit 2 xramm Shell Programming and Scripting 2 08-15-2007 09:48 AM
exit(0) versus exit(1) enuenu High Level Programming 9 06-22-2007 10:56 AM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 06:08 PM
exit value of the last run didi Shell Programming and Scripting 2 11-13-2001 11:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2006
rajpuneyani rajpuneyani is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
SSH to a server and exit out

Hi,
Can someone please help me in resolving this issue -

I am doing SSH from a server 1 to another server 2 and executing some statements there and then automatically exit out of second server to the first where script was getting executed.

Can you please help me script this code ?

Thanks
  #2 (permalink)  
Old 09-29-2006
rowan_sen rowan_sen is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 9
From a script on server1, you can run "ssh [user]@server2 [command]" and whatever is in [command] will execute on server2 as user [user].

You will be prompted for a password unless you set up public keys, which basically involves:
(Presume user running script on server1 is "fred" and logs in as "bob" on server2 to run commands listed in fred's script on server1.)
Run "ssh-keygen -t dsa" as whatever user uid the script will run from on server1 (fred). Press [enter] when prompted for passphrase (twice).
Copy ~fred/.ssh/.id_dsa.pub to ~bob/.shh/authorized_keys on server2.

Run "ssh server2 date" from fred's shell on server1 to confirm that you can log in as bob on server2 via ssh without a password. The first time you might have to reply with "yes" so that's another reason to test manually first.

If login fails (if it asks for a password) you might have to change permissions on ~bob/.ssh* on server2 to whatever the sshd server requires. Checks logs to confirm this.
  #3 (permalink)  
Old 09-29-2006
rajpuneyani rajpuneyani is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
Thank you sir,

It really helps a lot.
Appreciate you valuable time.

Regards
  #4 (permalink)  
Old 09-29-2006
tbdo88 tbdo88 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 11
Quote:
Originally Posted by rajpuneyani
Thank you sir,

It really helps a lot.
Appreciate you valuable time.

Regards

I think remsh perform the remote execution better than ssh.

remsh <servername> -n <command>
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 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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