Доступ к ключу SSH из сценария удара, работающего через задание крона

практика практики практики!

основы Schaum хороши для этого. Если Вы интересуетесь вероятностью (который затрагивает комбинаторику), см. 50 Бросать вызов проблемам в Вероятности.

6
задан Joel Hooks 4 November 2009 в 02:45
поделиться

2 ответа

I believe you are using the wrong kind of quotes. Plain-quoting ssh-agent doesn't do anything, you need to incorporate the results of running it by using command substitution with:

eval `ssh-agent`

or

eval $(ssh-agent)

This causes the script to set the needed environment variables. However, ssh-agent still will not have any keys unless you ssh-add them. If your keys have no passphrase, then ssh-add can simply be run from the script.

If your private key does have a passphrase, you might want to run this script as a daemon rather than a cron job. This would allow you to connect to the agent and add your private keys.

The real reason the script works from the command line is that your desktop environment is probably running ssh-agent and it arranges for the needed environment variables to be propagated to all your terminal windows. (Either by making them be children and inheriting the variables or by having your shell source the necessary commands.) I'm guessing you are running ssh-add at some point in your normal workflow?

7
ответ дан 10 December 2019 в 02:49
поделиться

The ssh-agent process only provides a facility to use with ssh-add to add your passphrase. It does not automatically make your key available (your private key cannot be decrypted without your passphrase).

In order to do this, you will need to create a passphraseless key and use that from the cron job. The usual safety warnings apply when using passphraseless keys.

2
ответ дан 10 December 2019 в 02:49
поделиться
Другие вопросы по тегам:

Похожие вопросы: