Visit Our UNIX and Linux User Community


SSH with a --password command line???


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SSH with a --password command line???
# 1  
Old 02-28-2008
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'?
# 2  
Old 02-28-2008
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 Smilie

Last edited by Smiling Dragon; 02-28-2008 at 11:38 PM..
# 3  
Old 02-28-2008
Quote:
Originally Posted by jjinno
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
... 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?
# 5  
Old 02-28-2008
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?
# 6  
Old 02-29-2008
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

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #870
Difficulty: Medium
Lisp introduced the concept of automatic garbage collection.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh remote command and print same line

john-test:/root> ssh -q chicago-ser uname;date Linux Fri Oct 13 16:41:11 GMT 2017 How I can print on the same line like this : Linux Fri Oct 13 16:41:11 GMT 2017 (2 Replies)
Discussion started by: jhonnyrip
2 Replies

2. Shell Programming and Scripting

Need one line command to create and set password for new user...

Using useradd abc --password password (5 Replies)
Discussion started by: Jagruti Rml
5 Replies

3. UNIX for Dummies Questions & Answers

Ssh command without password - Not working

Hi, I have followed the below commands for key generation and ssh from one server to another with user mqm cd /var/mqm/.ssh mqm@A:~> ssh-keygen -t rsa <public key creation> mqm@A:~> ssh mqm@B mkdir -p .ssh mqm@B's password: <entered_password> mqm@A:~> cat /var/mqm/.ssh/id_rsa.pub | ssh... (4 Replies)
Discussion started by: Anusha M
4 Replies

4. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

5. Shell Programming and Scripting

how to run a command line with another user without prompts for password

Hi, I'm writing a script, in the script I need to use tcpdump to capture some packets however it needs root priviledge my computer is configured by school and I have no real root priviledge so I can't use sudo on my computer,like Code: sudo tcpdump ...... I have to use a limited... (1 Reply)
Discussion started by: esolve
1 Replies

6. Shell Programming and Scripting

Script filling password from command line

I have this command that i am calling from php (exec()): openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12 and then i need to insert password twice Enter Export Password: Verifying - Enter Export Password: I need script that will fill the password... (3 Replies)
Discussion started by: rockyada
3 Replies

7. Shell Programming and Scripting

ssh command with password

hi: how can i use ssh with password in the command line . (4 Replies)
Discussion started by: rainboisterous
4 Replies

8. Shell Programming and Scripting

FTP command line username and password passing

Dear All, I am new to unix and I am trying to build a shell script which will connect to a different server by passing username and password from a file or command line but not manually... In short I dont want to connect to a diff server via ftp interactively. Any suggestion...looking... (8 Replies)
Discussion started by: Pratik4891
8 Replies

9. UNIX for Advanced & Expert Users

How to use SFTP from command line without entering user and password

I would like to use SFTP from command line without entering userid and password. Here is what I have gathered and did. 1) Create a public and private key pair for the protocol you want to use. To create a key pair for use by SSH2, enter: ssh-keygen -t dsa I did that and got... (7 Replies)
Discussion started by: Hangman2
7 Replies

10. Shell Programming and Scripting

How do I get ssh to run a command in one line?

How would I combine something like: localserver# ssh remoteserver remoteserver# find blah blah blah into a one liner that would ssh to the remote server and run the find command, so I could put it in a script to automatically go out and run things on remote servers with out needed user... (2 Replies)
Discussion started by: LordJezo
2 Replies

Featured Tech Videos