[OT] ssh login script - Please Help

Bill Davidsen davidsen at tmr.com
Fri May 8 16:35:42 UTC 2009


Mikkel L. Ellertson wrote:
> Mike Burger wrote:
>> Mikkel wrote:
>>> Or don't log in at all. Use scp to copy the file, and then ssh where
>>> it is set to run a command when you connect. (Use the
>>> comand="comand" format for the key.) One thing I am not sure of is
>>> if you can use the same key for scp when using the command= option.
>> Well, is part of the openssh suite, and does/will use the same key as the
>> ssh executable.
>>
>> I use keys to scp and ssh to run commands all the time, without having to
>> pass passwords along, in order to automate processes, all the time.
>>
> I do the same. But I have never tried to use the private key that
> was tied to a command on the other machine with scp, so I do not
> know if scp will work with a key that is only allowed to run one
> program on the remote machine. (You can not "login" in using that
> key.)

[ forgive my mid-line snip of your example ]

You don't need to do two operations, you can pass the file to the script:
   cat myfile | ssh -i myscript.key machine [optional args]
the first command in the script is something like:
   dd of=safedir/new.myfile

You can pass arguments to the script, they will end up in $SSH_ORIGINAL_COMMAND 
which can be read by the script. My backup script takes 
full|incr|config|logs|crit argument on the client and sends the backup data to 
stdout where I can save it.

-- 
Bill Davidsen <davidsen at tmr.com>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot




More information about the users mailing list