Solved

SSH Login Script

Posted on 2003-11-12
3
24,761 Views
Last Modified: 2013-12-23
I have research a few things and have ideas about this, so for me to accept an answer, I will need a fairly detailed answer ( but I will award more points if needed to accomplish this ).

I have used public key based authentication with SSH before and though it is a good solution, it is not the right solution for this issue.  I have hundreds of server that I wish to ssh to serially in a script... I want the script to prompt me for a password like:

echo Enter your passwd
stty -echo
read PASSWORD
stty echo

and I want to be able to pass that result as an environment variable of parameter to SSH.  I have done this successfully with FTP and with RSYNC.

I had considered and played with ssh-agent ( which would have been great ), but I even after I ssh-add ed my private key, it continues to prompt me on the remote hosts for login, which just won't fly with having to login several hundred times.  So maybe I could also get along with a fix or better understanding of why my ssh-agent is not working properly, but I would also like to know if I can simply read input and pass it to SSH.

0
Comment
Question by:stewbeast
  • 2
3 Comments
 
LVL 40

Assisted Solution

by:jlevie
jlevie earned 100 total points
Comment Utility
From your question it sound like this is probably a job for expect, but I'd need to know more about what your script will be doing to be able to propose a solution.
0
 
LVL 38

Accepted Solution

by:
yuzh earned 150 total points
Comment Utility
Agreed with  jlevie ,

    If you do want to setup ssh without password, you need to use "expect" script to handle the
password, if you don't know kow to write an expect script, use autoexpect to create one for you.

man autoexpect

to learn more.

In case you don't have expect install on your system, you need to download it for you version
of OS, You should also get tcl , tk installed on your system.  (just do a search on the web, you
can find them)

information about expect (including script example can be found):

http://expect.nist.gov/

you can also use "autoexpect" to create an expect script for you and then modify
the script
man autoexpect

Have a look at the following example to get soem idea about expect script:
http://oldlook-search.experts-exchange.com/Operating_Systems/Linux/Q_20476614.html

if you want more help for the expect script, please let us know how would you use the
script, eg, commandline format, args (hostname, login-name, passwd etc) to pass to the script .


0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
How's it going, need more help?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now