Monday, October 10, 2011

Generate SSH Key on Linux for Android

If you need to generate an SSH key pair on your Linux PC for your Android device (i.e. ConnectBot or AndFTP), here's how I did it.

ssh-keygen -b 2048 -C Droid2 -t rsa -f id_rsa_droid2

Then the private key only needs to reside on the Android device (then import into software that needs it), and the contents of the public key need to be added onto the .ssh/authorized_keys file on every remote host you desire to ssh into from the Android device. One way is to get the public key file on the remote host, then enter

cat id_rsa_droid2.pub >> .ssh/authorized_keys

(the ">>" says to append the contents of id_rsa_droid2.pub to the end of the authorized_keys file)

If I find a better way—for example generating an OpenSSH-compatible keypair on the actual Android device—I'll post it.

2 comments:

  1. This is a decent way to generate your ssh key on an android device, but the ConnectBot app may require a rooted device. Also, password authentication needs to be temporarily enabled to allow for the initial connection so that you may add the authorized key

    http://michaelchelen.net/articles/android-connectbot-ssh-key-auth-howto.html

    ReplyDelete
  2. thank you for this! Jesus christ I have been looking all over the place to make it work with andftp

    ReplyDelete