Solved

SSH Login Script

Posted on 2003-11-12
3
24,766 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
ID: 9735832
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
ID: 9736271
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
ID: 9761620
How's it going, need more help?
0

Featured Post

Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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.

863 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

19 Experts available now in Live!

Get 1:1 Help Now