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
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 01:25 PM
bash ssh login script modcan Shell Programming and Scripting 2 06-04-2008 02:39 AM
Why generate "ash and bash" different output for same bash script? s. murat Shell Programming and Scripting 0 05-26-2008 08:19 AM
How to get bash to be the login shell? amheck SUN Solaris 8 03-10-2006 05:39 PM
bash script help!!! shooroop Shell Programming and Scripting 3 10-06-2005 08:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-25-2007
big_pil big_pil is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
Unhappy bash script for ssh login-

hi.
I need a bash script which can login to an other mashin via SSH and then run some commands and then return the result to my mashine.
I dont know where to begin, I think first I will need a ssh connection, dont know how to make it,
then , do I need a ftp connection between the 2 mashins to transfare data/files from mashine2 to mashine1 ?
is this things possible in bash ? it should be..
Please help.
  #2 (permalink)  
Old 10-25-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by big_pil View Post
hi.
I need a bash script which can login to an other mashin via SSH and then run some commands and then return the result to my mashine.
I dont know where to begin, I think first I will need a ssh connection, dont know how to make it,
then , do I need a ftp connection between the 2 mashins to transfare data/files from mashine2 to mashine1 ?
is this things possible in bash ? it should be..

Create public and private keys (with ssh-keygen -- read the man page) and install them.

Then you can use a command like:

Code:
remoteuser=myname
remotecomputer=example.com
ssh -l "$remoteuser" "$remotecomputer" "ls -l; date; "
To capture the result either redirect it to a file or store it in a variable with command substitution.
  #3 (permalink)  
Old 10-26-2007
big_pil big_pil is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
what about password ?

Hi.. I ran your script and it did work well, but I needed to type the password, how can I do it if I want the password inside the script ? so it runs automaticly without asking about password ?
  #4 (permalink)  
Old 10-26-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by big_pil View Post
Hi.. I ran your script and it did work well, but I needed to type the password, how can I do it if I want the password inside the script ? so it runs automaticly without asking about password ?

I repeat:
Create public and private keys (with ssh-keygen -- read the man page)
and install them.

  #5 (permalink)  
Old 10-26-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by big_pil View Post
Hi.. I ran your script and it did work well, but I needed to type the password, how can I do it if I want the password inside the script ? so it runs automaticly without asking about password ?
On the server, the public key should be appended to $HOME/.ssh/authorized_keys

on the client, the private key should go in '$HOME/.ssh', called id_XXX depending on the type of key.

The key pair should be made without password.

SSH User Identities
  #6 (permalink)  
Old 10-29-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
u can use ssh -l username IP "cmd"
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 05:54 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