How to Passwordless SSH to an OpenWrt Router?

Posted on In QA

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"

Eric Ma

Eric is a 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.

3 comments

  1. you can use ssh-copy-id to manage keys when you you run

    ln -s /root/.ssh/authorized_keys /etc/dropbear/authorized_keys

Leave a Reply

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