How to Passwordless SSH to an OpenWrt Router?

The good ssh-copy-id method which works well on common Linux seems not working for OpenWrt router.

How to Passwordless SSH to an OpenWrt Router?

OpenWrt’s SSH server is Dropbear. It can accept normal RSA keys. But the authorized_keys location is not the same as the openssh “~/.ssh/authorized_keys”.

The location for the authorized_keys is

/etc/dropbear/authorized_keys

What you need to do is to put your public key to that file. If you use the default key location ~/.ssh/id_ras.pub, you can do it by this command:

ssh root@YOUR_OPENWRT_ROUTER 
cp /etc/dropbear/authorized_keys /etc/dropbear/authorized_keys.bak

cat ~/.ssh/id_rsa.pub 
| ssh root@YOUR_OPENWRT_ROUTER "cat >> /etc/dropbear/authorized_keys"
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *