Re: how to pass passcode to a command?

Nico Kadel-Garcia wrote:
amit wrote:
Nico Kadel-Garcia wrote:
"amit" <amit.kohan@xxxxxxxxx> wrote in message

Hi group,

I'm writing a bash script and part of the code is connection
between to machine so I need to have password to pass to the

Now, how can I redirect the password question? is it possible to
redirect it to /dev/null and somehow write a code to ask for
password in a managed way and pass it to the command. Let's say the
command is scp.

scp localmachine root@remotemachine:/tmp

or maybe it won't be safe?!! any suggestions?

You could learn to use "expect", or better yet you could learn to
use SSH keys and ssh-agent to avoid the need to retype passwords.

Hi Nico,

I usually use ssh but dont' know how to use SSH keys an ssh-agnets.
Any online article?

Well, there's the O'Reilly book by Richard Silverman, the manpage for
ssh-agent, the keychain utility that is available for most Linux
distributions, and gazillions of webpage how-to's out there, such as

Thanks indeed for your help.