[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using multiple keys with ssh-agent



I want to be able to ssh into machine "remote" and have pine start
automatically.  But I also want to be able to ssh in and have a normal
shell.

So, I created a new key pair with:

     ssh-keygen -t dsa -f id_dsa_pine

then added the new public key to remote's .ssh/authorized_keys2 file.  I
also prepended command="pine -i" to that new public key.

So, I can now go

   ssh remote

and get a remote shell.  Or I can type

   ssh -i id_dsa_pine remote

and I connect and pine runs right away.  Cool.  Now I can use two buttons
on my icewm taskbar to select mail (ssh -i id_dsa_pine remote) or just a
shell (ssh remote, or ssh -i id_dsa remote).

The problem is I use ssh-agent and ssh-add (in .xsession) and then I
cannot specify the -i switch when running ssh.  Regardless of the ssh -i
command it always connects with the key that was added first with ssh-add.

To be clear, if in .xsession I have:

  ssh-add  $HOME/.ssh/id_dsa  $HOME/.ssh/id_dsa_pine < /dev/null &

then when I "ssh remote" (regardless of the -i I pass to ssh) it connects
with the id_dsa key which just runs the shell.

But, if i .xsession I reverse the order the keys are added:

  ssh-add  $HOME/.ssh/id_dsa_pine  $HOME/.ssh/id_dsa < /dev/null &

then running "ssh remote" uses theid_dsa_pine key pair and then runs pine
on the remote machine.

Any tricks to signal ssh-agent which key set to use when running ssh?




-- 
Bill Moseley moseley@hank.org



Reply to: