"redirecting input" in a unix shell script with su

"redirecting input" in a unix shell script with su

am 01.10.2007 10:33:10 von gerry.brennan

I am trying to do the following

su - operator -c "ssh-keygen -t dsa -f ~/.ssh/id_dsa << EOF


EOF"

from a ksh script

But each time I run it I have to press carriage return twice ...

When I run the above with out the "su -operator -c"

It works fine.

Re: "redirecting input" in a unix shell script with su

am 01.10.2007 17:26:34 von Icarus Sparry

On Mon, 01 Oct 2007 01:33:10 -0700, gerry.brennan wrote:

> I am trying to do the following
>
> su - operator -c "ssh-keygen -t dsa -f ~/.ssh/id_dsa << EOF
>
>
> EOF"
>
> from a ksh script
>
> But each time I run it I have to press carriage return twice ...
>
> When I run the above with out the "su -operator -c"
>
> It works fine.

The version of ssh-keygen I have does a number of things to get the
password.

It looks to see if the standard input is connected to a terminal.
If not then it either calls ssh-askpass or it opens /dev/tty, and reads
from that. This explains why you have to press enter twice.

At least my version of ssh-keygen has a -N flag so you can say

su - operator -c "ssh-keyget -N '' -t dsa -f ~/.ssh/id_dsa"