Re: configuring ssh-agent to automate passphrase for the key

From: Pierre Asselin (pa_at_see.signature.invalid)
Date: 12/28/04


Date: Tue, 28 Dec 2004 01:14:47 +0000 (UTC)

Javed <kjaved@ncs.com.sg> wrote:

> [ ... ]
> during iniating the connection we are prompted for the passphrase of
> the key. The passphrase is a must for our requirement.

Requirement duly noted.

> Our requirement is to automate the entry of passphrase, means there
> shouldn't be any human intervention.

This second requirement contradicts the first. A human *has* to enter
the passphrase at least once, otherwise your system is somehow deafeating
security by storing the passphrase in the clear.

You can use ssh-agent to create an intermediate system where the
passphrase is entered only once. (It should be "once per day" or
"once per session", otherwise you are effectively back to a system
without a passphrase.) ssh-agent is used from the command line
in the following way:

    $ eval $(ssh-agent -s)

The command "ssh-agent -s" creates a background process (the agent)
and prints output that looks like this:
    SSH_AUTH_SOCK=/tmp/ssh-OsrzU24442/agent.24442; export SSH_AUTH_SOCK;
    SSH_AGENT_PID=24443; export SSH_AGENT_PID;
    echo Agent pid 24443;

when captured in a shell $(...) construct and passed to the shell "eval"
function, it causes the parent shell to create the environment variables
SSH_AUTH_SOCK and SSH_AGENT_PID. The first of these is used to communicate
with the background agent. The second variable, SSH_AGENT_PID, is used
only to stop a running agent, via the command
    eval $(ssh-agent -k)

All processes subsequently started by the shell have a copy of
these variables.

After starting the agent, you load the private key:

    $ ssh-add
    Enter passphrase for <key file>:

and it is the "ssh-add" command that prompts you for a passphrase.
The "ssh-add" command uses $SSH_AUTH_SOCK to communicate with the agent.

At this point, all ssh processes started by this shell, or by other
processes started by this shell, can usie $SSH_AUTH_SOCK to obtain
signatures from the agent. Maybe all you need to do is run ssh-agent
and ssh-add before starting your Oracle thing for the day.

If you need use the agent from processes that are not descendents
of your starting shell, for example cron jobs, then those processes
will have to search for the running agent's socket. They should
look in /tmp for a directory of the form "ssh-*" containing a single
file "agent.*", of type "socket", owned by their userid and to
which they have read and write permission. They can then set their
own SSH_AUTH_SOCK environment variable to the name of the socket,
after which they will be able to run ssh commands that use the
private key.

Your policy could require a human officer to start an agent in the
morning and kill it at the end of the business day, for example.

-- 
pa at panix dot com


Relevant Pages

  • Re: Auto ssh
    ... > Process, machines A and B. ... > Alternatively you can use this command to do this for you: ... > then you tell it the passphrase which it remembers. ... > agent to forget the passphrases after so long. ...
    (comp.unix.aix)
  • Re: ssh without entering password/passphrase
    ... I created private and public key pairs in my local host ... > this point when I try to ssh, it asks for my passphrase and I can log ... "Could not open connection to your authentication agent". ... What you are missing is that just having ssh-agent run is not enough. ...
    (comp.os.linux.misc)
  • Re: How do I execute dos command without a path
    ... > gpg: no valid OpenPGP data found. ... > I know the command is valid and this variation works also ... > Reading passphrase from file descriptor 0 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: OpenSSH 2.9p2: ssh-keygen bus errors
    ... > the same version of OpenSSH installed, ... > after I enter my old passphrase. ... Is this a known bug? ... I have OpenSSH version 2.9p2 on Solaris 8, and the above command works ...
    (comp.security.ssh)
  • RE: Going MAD trying to get scp working on Solaris8 - Horah - Its res olved - Or Is it....
    ... The ssh-agent will indeed hold keys for use by ssh related programs. ... The key to what you want to accomplish is to make sure a SINGLE agent is ... working without entering a password or passphrase. ...
    (SSH)