SSH Pubkey Setup In One Command

Monday, February 14, 2005.

Transfer your ssh public key to a remote host, for passwordless logins, in one command:

ssh < "$key" "$@" '
  cat > $HOME/authorized_keys && 
  mkdir -p .ssh &&
  cat $HOME/authorized_keys >> $HOME/.ssh/authorized_keys &&
  rm -f $HOME/authorized_keys &&
  chmod 0700 .ssh &&
  chmod 0600 $HOME/.ssh/authorized_keys'

Note that newer versions of ssh now have ssh-copy-id(1).

Posted by Alan on Monday, February 14, 2005. (Discuss)

blog comments powered by Disqus
maelstrom

"After a little while I became possessed with the keenest curiosity about the whirl itself. I positively felt a wish to explore its depths, even at the sacrifice I was going to make; and my principal grief was that I should never be able to tell my old companions on shore about the mysteries I should see."

Illustration for Edgar Allan Poe's story "Descent into the Maelstrom" by Harry Clarke, published in 1919.