The UNIX and Linux Forums  

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
log session mm00123 Linux 15 03-24-2008 03:27 AM
sqlplus session being able to see unix variables session within a script 435 Gavea Shell Programming and Scripting 2 07-03-2006 11:11 AM
Inactive Session lowtaiwah UNIX for Dummies Questions & Answers 12 06-22-2006 12:37 AM
Telnet Session pathanjalireddy Shell Programming and Scripting 6 04-06-2005 11:41 AM
is it possible to ssh within an ssh session? noamkrief UNIX for Dummies Questions & Answers 4 11-14-2003 05:16 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 08-27-2007
jjinno jjinno is offline
Registered User
  
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 72
scripting an ssh session?

I know the root login/password for a machines, and I want to automate some commands like this from each:

Code:
ssh root@remoteHost1 "tail /var/log/messages"
ssh root@remoteHost2 "tail /var/log/messages"
ssh root@remoteHost3 "tail /var/log/messages"
ssh root@remoteHost4 "tail /var/log/messages"
ssh root@remoteHost5 "tail /var/log/messages"

My only problem is that I cant guarantee that the keys and such exist every time, cause there is often re-imaging done without my knowledge... and I dont want to enter "yes" and my password 6 times each time I wanna run my script... so I need to setup something like passwordless ssh but using a script to set it up, and then another script to run my commands... or both in one script, doesn't matter to me...

Is this doable? or is it possible to constantly check STDIN, and when it matches /password\:/ then I pipe it my password, and if it matches /\(yes\/no\)/ then I know to pipe it "yes"... but then how would I mimic the enter key, cause Im pretty sure "\n" is not enter, but just a new line

any help here?
  #2 (permalink)  
Old 08-27-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
1. Get your public key into the image.

* OR *

2. Get the people who do the re-imaging to re-install your key when they re-image.

* OR *

3. ssh to your own machine taking an input file but use the option to allocate a pseudo-terminal, then in that ssh shell do the ssh to the actual target.

Basically to get the password entered you should have a terminal allocated.
  #3 (permalink)  
Old 08-28-2007
jjinno jjinno is offline
Registered User
  
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 72
Thanks for the reply

I think I found a CPAN module that will allow me to use both a username and password

Net::SSH

Seems like it is a fully loaded SSH session within Perl, so will do what I need it to.
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 06:39 AM.


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