SSH with a --password command line??? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

SSH with a --password command line???

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-28-2008
jjinno jjinno is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 15 January 2014, 2:49 PM EST
Location: Cloud 9
Posts: 92
Thanks: 2
Thanked 2 Times in 2 Posts
SSH with a --password command line???

Has anyone heard of an OpenSSH client being compiled with an additional command-line option for password input?

I realize there are reasons to NOT do this, and I realize you can achieve the same type of thing with keys, but I am specifically looking to pass the username & password BOTH on the command line... (IE - allowing for one-shot remote commands)


Code:
# myssh root@10.20.30.40 --password=myP@ssw0rd "uname -a"

currently there is a script in place of myssh that uses Expect and Tcl to capture the output of the system-default SSH, but I would like to get rid of it and use a straight binary if possible.

Any ideas? Or should I go back to brushing up on my C/C++ and compile the option into my own version called 'myssh'?
Sponsored Links
    #2  
Old 02-28-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
 
Join Date: Nov 2007
Last Activity: 17 June 2014, 10:55 PM EDT
Location: New Zealand
Posts: 1,035
Thanks: 20
Thanked 23 Times in 22 Posts
You could use 'expect' and a wrapper script to do it I guess.

Edit: Ah, I see you've already done this, I really should read properly

Last edited by Smiling Dragon; 02-28-2008 at 09:38 PM..
Sponsored Links
    #3  
Old 02-28-2008
jjinno jjinno is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 15 January 2014, 2:49 PM EST
Location: Cloud 9
Posts: 92
Thanks: 2
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by jjinno View Post
currently there is a script in place of myssh that uses Expect and Tcl to capture the output
I am, and it really is quite terrible when it comes to environmental variables like columns, colors, escape sequences, and not to mention quoting.

I even tried re-creating the same script with the Python PxSSH module (using pExpect module) and came up with ultimately the same exact hangup:
Quote:
tput: No value for $TERM and no -T specified
This is what I get when I try to do something like running the Dell OpenManage service startup script. (I think caused by locking or trapping) Either way, this may not be the root problem, though it is the only error displayed. The root problem is that even though the script runs, the return never happens, so Expect times out the session, calling it a failure.
    #4  
Old 02-28-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
 
Join Date: May 2006
Last Activity: 4 May 2012, 3:37 PM EDT
Location: Tau Ceti V
Posts: 558
Thanks: 0
Thanked 7 Times in 6 Posts
... maybe I am missing something here. You want to do one-shot remote commands? Why can't you do that with the 'regular" ssh and keys?
Sponsored Links
    #5  
Old 02-28-2008
jjinno jjinno is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 15 January 2014, 2:49 PM EST
Location: Cloud 9
Posts: 92
Thanks: 2
Thanked 2 Times in 2 Posts
The scenario is as follows:

You have a "system" that is comprised of N servers. This system can change in size both plus and minus (from 1 to 512 - just for kicks) individual servers. These replacements/additions all have unique IP addresses, but have a broadcast response system that can identify "all the other IPs that I need to talk to". ("I" being the server)

Given MY way, I do not need to do ANYTHING except run a bash script that uses MY SSH, logs in to every server, runs whatever I want, and pushes the output back to my terminal. This version of SSH would reside on MY machine, and would be completely compliant with their SSH daemon...

Using keys, I have to at a minimum send a file (the key) to the remote machine before communication, and that may be fine for ME to do in the lab. For someone in the field, (aka NOT me) I don't want to have to explain the details of Passwordless SSH & Keys. Especially to somebody that doesn't want/need to know.

Is this really that bizarre of a concept?
Sponsored Links
    #6  
Old 02-29-2008
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
 
Join Date: Nov 2006
Last Activity: 20 November 2013, 8:29 AM EST
Location: Bulgaria
Posts: 1,419
Thanks: 0
Thanked 6 Times in 6 Posts
will this work ?

cat myssh.tcl

Code:
#!/usr/bin/expect

set timeout -1

if { $argc != 4 } {
    puts "Usage $argv0 host user pass command"
    exit 1
}

set host [lindex $argv 0]
set user [lindex $argv 1]
set pass [lindex $argv 2]
set command [lindex $argv 3]

spawn sftp -oStrictHostKeyChecking=no -oCheckHostIP=no $user@$host
expect *assword:

send "$pass\r"
expect sftp>

send "$command\r"
expect sftp>

send "exit\r"
expect eof

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script filling password from command line rockyada Shell Programming and Scripting 3 01-11-2012 11:38 AM
SFTP with Password in Command Line st3636 UNIX for Dummies Questions & Answers 1 08-06-2011 01:47 PM
FTP command line username and password passing Pratik4891 Shell Programming and Scripting 8 06-10-2010 10:33 AM
How to use SFTP from command line without entering user and password Hangman2 UNIX for Advanced & Expert Users 7 03-07-2009 02:22 AM
Single line password reset. margi973 UNIX for Dummies Questions & Answers 2 01-20-2004 03:14 AM



All times are GMT -4. The time now is 04:56 AM.