I would like to copy an ssh key to my Android phone. However, I have displaced the connection cable for my computer. I am looking for a safe way to transfer the key to the device.

Obviously, I don't want to send it to my device using email (attack vectors everywhere). Using bluetooth is not an option since my laptop doesn't support it. I could transfer the key safely to my server via SSH and then copy it back using Password authentification, but I feel like there must be a "cleaner" way of doing this that doesn't involve broadcasting the keys into the internet in some form.

  • I'm assuming manually typing this key is not a possibility due to time? – Ohnana Dec 23 '14 at 14:57
  • I thought about it, it would be the safest option, I guess. But I wanted to ask here to see if someone has another clever idea ;-) – chaosflaws Dec 23 '14 at 15:03
  • Which phone manufacturer? – k1DBLITZ Dec 24 '14 at 15:50
  • It is a Samsung Galaxy Note II. – chaosflaws Dec 24 '14 at 16:56
  • 3
    Sidenote : don't copy it. Make a new one on the phone itself and tell your server to trust it; if it ever gets compromised you can revoke that key without revoking your computer's key. – user42178 Dec 24 '14 at 17:13
up vote 8 down vote accepted

You might want to try using a QR code to copy the key over. Generate the QR code on the laptop and scan it using your phone's camera. Obviously, dont use an online service to generate it, linux has a qrencode library which does that.

I have tried converting my PGP public key into a QR code and the phone successfully read it. However, if your ssh key is too long, you might have to split it up into sections.

  • I would do this too. It's easy and if you convert it offline, it's "secure". – Gerifield Dec 23 '14 at 15:37
  • 2
    Make sure you create the QR code from the encrypted key. – RoraΖ Dec 23 '14 at 17:01
  • Good step, @RoraΖ, and then decrypt the key on the mobile device. – Viet Dec 13 '17 at 11:02
  • @limbenjamin if the key is too long, one should consider using Ed25519 instead of RSA for SSH keys :) – Viet Dec 13 '17 at 11:04

Set up a LAN FTP server on your phone, and access it from your computer's file manager by typing the address in the path bar. From there, it's just a copy and paste matter. If you don't trust your local network from possible sniffers, use SFTP instead of FTP.

I used an Open Source FTP client I don't remember its name. But you can also use ES File Explorer (it has an FTP server called "Remote Manager") only AFTER you install AFWall+ and block that from accessing the Internet and only allow it to use network permissions for LAN connections. I don't particularity trust that app, but damn it's so essential and versatile.

Finally, the answer was to put my phone's micro sd card into the sd card slot of my computer. Took me a while to get there...

Anyway, it wasn't obvious from the question this was possible, so I'll accept the answer I consider to be the best practice here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.