How to ssh from a shell script ? For ppl who can write shell scripts.
I have asked related questions before. I am asking again because I donot have the answer yet.
Hoe to use ssh in a shell script? When I use it normally it asks for a password. SSH through RSA or DSA authentication does not work here in the machines I use. Is it possible to program the shell in such a way that the password is entered somewhere and the command doesnt ask for it during execution. (I have to run ssh in a loop). ssh does not come with any option to spicify the password in the single command line I guess. A question for the shell programming experts out there.. :) Thanks for your time Ash |
This does the job:
http://sourceforge.net/project/showf...roup_id=156659 However, you'll have to compile and install if from source to be able to integrate it into you shell script. |
See this,
http://www.hostingrails.com/forums/wiki_thread/27 simple and easy solution. Even I learnt it from here. |
Use 'expect' command to automatically enter the username and password, if RSA key copying to target doesnt works.
in shell script use ssh as "ssh target_ip file_or_cmd_to_execute" Thats it. |
copy your rsa key.pub to the machine you want to log in, or use ssh-copy-id in the script... youll have to enter your password once and no more..!
|
I've moved this thread to the programming forum because I think its more appropriate there since you are looking to do resolve your problem using a shell script.
|
Quote:
|
Will RSH work for you?
|
don't use rsh: http://www.informit.com/articles/art...p=169465&rll=1
|
Quote:
I think it all comes down to how secure your whole system is. I work for one of the worlds biggest investment companys. We have an IT budget of over $1 billion a year. If it was that big an issue, you can bet we would change it. |
I've worked for some very large ones myself, eg Merchant Banks :)
Obviously its up to 'you', but no matter how big the company, it doesn't make the protocol any safer, and you can do the same work with ssh/scp/sftp ... |
Running RSH is like leaving your house keys under the welcome mat.
RTEFA, Read the excellent ;) article, it begins:
"Running RSH is like leaving your house keys under the welcome mat." Printer friendly link: http://www.informit.com/articles/pri....aspx?p=169465 It goes on to answer the objection, "But our network is strictly switched, and security is good. No one can penetrate our perimeter!"; as well as to discuss how to move to ssh. &BTW, since when were banks smart or long sighted? |
Absolutely, size and/or money doesn't automatically confer intelligence...
:) |
Quote:
The OP mentioned password instead of passphrase. The password authentication is being requested by the server, such as using PAM instead of the passphrase which is used locally on the client to unlock the client's own private key. |
Agreed. I have used ssh-agent before & expect to start doing so again. I asked because the statement
Quote:
Quote:
It would be nice if OP would clarify. |
All times are GMT -5. The time now is 09:08 AM. |