Cannot ssh from OpenWrt to other Host using ~/.ssh/config


I am using latest Snapshot on Pi 4.
I want to ssh from OpenWrt command line to another host on the same LAN.

I converted the private open-ssh key of the other host to dropbear format and saved it to ~/.ssh/ncp_key_dropbear.

Now I can ssh to that host from OpenWrt like this:
# ssh -i ncp_key_dropbear root@ -p 22

I also made a ~/.ssh/config file like this:

Host ncp
        User root
        Port 22
        IdentityFile ~/.ssh/ncp_key_dropbear

But when I try to ssh now with this command:
# ssh ncp

I get this error...

root@OpenWrt:~/.ssh# ssh ncp

ssh: Connection to root@ncp:22 exited: Connect failed: Error resolving 'ncp' port '22'. Name does not resolve

I set up a ~/.ssh/config file on the other host as above and can ssh from it to OpenWrt like this:
# ssh openwrt

So why is my config file not working on OpenWrt?



I'm guessing that ping ncp won't resolve the name either, so that's the basis of the problem, not anything specific to ssh. In order to resolve LAN names from OpenWrt running as a LAN device you have to disable rebind protection in the DHCP/DNS config.

Full OpenSSH is available as a package as an alternative to dropbear client.

1 Like


I disabled rebind protection in the DHCP/DNS config but still getting the same error, same thing after a reboot too.

I don't fully understand it all but you're right ncp is not a hostname in my lan so ping ncp won't resolve to anything.

I thought ncp here is just a placeholder and ssh will look for a config file in ~/.ssh directory and then if found try to match ncp on a Host entry in ~/.ssh/config then take the rest of the details like Port, hostname and identity file from there too.

The ssh server on the other host IS listening on port 1022 as well. If I put Port 1022 into ~/.ssh/config I still get the error:

root@OpenWrt:/etc/dropbear# ssh ncp

ssh: Connection to root@ncp:22 exited: Connect failed: Error resolving 'ncp' port '22'. Name does not resolve

It still thinks I'm trying to connect to Port 22 instead of 1022? So maybe dropbear is not looking for my config in ~/.ssh/config?

I also tried putting that config file in /etc/dropbear.. is that where it is suppose to be?

Still don't get why this command work whens I run it in OpenWrt?
# ssh -i ncp_key_dropbear root@ -p 22
but this command does not..
ssh ncp



Set up shell aliases, or install this package replacing the Dropbear SSH client:

1 Like


Yes I was looking at this article suggesting shell aliases.

But is that it so for definate? Dropbear doesn't know anything about ~/.ssh/config files?


1 Like

It seems so.

I got confirmation from the author that Dropbear does not currently support a ~/.ssh/config file.

I installed the OpenSSH client which then replaces Dropbear as the OpenWrt ssh client and it does recognise that configuration file.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.