How to Passwordless SSH to an OpenWrt Router?
Posted on In QAThe 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"
you can use ssh-copy-id to manage keys when you you run
ln -s /root/.ssh/authorized_keys /etc/dropbear/authorized_keys
Nice tip!
good idea!