![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
Quote:
I think remsh perform the remote execution better than ssh. remsh <servername> -n <command> |
| Sponsored Links | ||
|
|