Friday, March 2, 2012

Configuring SSH: Creating a Command Key

OpenSSH provides the capability of binding a particular key to a command.  This is often the best way to execute a remote command without the risk of sending a password over the network.

  1. Change directory to your .ssh directory. (ie. cd ~/.ssh)
  2. Create the key pair. (ie. ssh-keygen -N "" -f hello_world)
  3. Add the key to the authorized_keys file along with the command. (ie. echo -n 'command="echo Hello World"' | cat - >> authorized_keys)
  4. Try it out! (ie. SSH_AUTH_SOCK=/dev/null ssh -o BatchMode=true -qi hello_world localhost)

No comments:

Post a Comment