Unable to SSH into my DietPi device

I have a Nanopi Neo3, ive downloaded the DietPi image and dd it to my microsd card.

ive connected direct ethernet cable from pc to my neo3, and i can successfully ping it at addr 192.168.0.100

but when trying to connect via ssh to root@192.168.0.100 or just 192.168.0.100
the result is always

connect to host 192.168.0.100 port 22: Connection refused

ive also tried puTTy, same response

Any advice?

Are you sure this is the correct IP address? Usually IP address are assigned via DHCP and you would need to check your router which IP has been assigned

My device is plugged directly into my pc via ethernet cable, not a router and dhcp

I set the static IP myself in /etc/network/interfaces file

auto eth0
iface eth0 inet static
 address 192.168.0.100
 netmask 255.255.255.0
 gateway 192.168.0.1
 dns-nameservers 127.0.0.1

This configuration might not gonna work as your gateway is pointing to 192.168.0.1. is this the IP address you are using on your computer as well on that particular interface?

no, the ip on my pc is completely different. 192.168.3.56

If you connect the SBC directly to you desktop, you should configure both adapter to match

@Joulinar can you elaborate? I dont know what you mean.

I would be willing to pay if anybody can help me get around this problem, ive spent now over 12 hours and im getting nowhere.

You need to configure the ethernet interface on your desktop computer where you plugged the Neo in. Both, your computer and the neo need to have a an IP address from the same IP address segment.

Yea, make die they are in the same subnet and delete the gateway entry.

https://www.circuitbasics.com/how-to-connect-to-a-raspberry-pi-directly-with-an-ethernet-cable/

@Joulinar when I posted above re adding static ip to /etc/network/interfaces - that was on the desktop computer.

I havnt been able to add anything to the DietPi device as I cannot connect to it, due to this ethernet problem.

do I definitely need to have config on the dietpi device aswell as my machine, or just the host machine?

You can just connect a keyboard and a display to the PI and configure it, otherwise you need to set this up before you run the first boot installation:
https://dietpi.com/docs/usage/#how-to-do-an-automatic-base-installation-at-first-boot-dietpi-automation

Or you connect both devices to a DHCP server and let it manage IP config for you.

1 Like

Do you mean that you have configured the IP address 192.168.0.100 on your desktop computer? Of course this will not work because you have assigned the IP address to your desktop and not to the Neo. This also explains why ping works, because you have pinged your desktop :wink: . As mentioned in my very first post, DietPi uses DHCP by default and you need to configure a STATIC IP in the dietpi.txt file before the first start. @Jappe has posted the corresponding link to our online docs above already.

@Jappe thanks for the link and alternative way, il consider it.
Is this connection problem possibly because my host pc may not have a dhcp server?

@Joulinar no I dont mean that, I assigned the ip address(not my machine ip, a different ip) 192…to the ethernet adapter interface, ie whatever device gets plugged into the ethernet adapter, is assigned this ip.

which is why i hoped ping was correct.

as for dietpi using dhcp, my linux machine isnt able to find the ip via the ethernet usb adapter, hence why i made this post - i cant seem to connect.

another thing which may help troubleshooting - I have only copied the dietpi iso/img to the sd card, if modifications are expected, i havnt done any.

The interface that you configure on your desktop is used by your desktop. This IP is not assigned to a device that you connect. Each device must be configured in its own configuration. You cannot assign a STATIC IP remotely. This means that you must flash a new image onto your SD card. You should then be able to access the SD vfat setup partition to make the initial configurations.

@Joulinar as my desktop is the host(acting as a router) i thought that was responsible for assigning the static ip??

eg in my above post

iface eth0 inet static
address 192.168.0.100

if ive got this wrong, how do routers assign ip remotely?

this would require a DHCP server software on your desktop

@Jappe already shared the link to our online docs where we explain how you can pre-configure IP settings

@Joulinar
@Jappe

I followed the instructions and modified /boot/dietpi.txt

still cannot connect.

Below is the following things I changed.

# Set to "1" to convert DHCP leased network settings into static settings automatically on first boot.
AUTO_SETUP_DHCP_TO_STATIC=1
# Enter your static network details below, if applicable.
AUTO_SETUP_NET_USESTATIC=1
AUTO_SETUP_NET_STATIC_IP=192.168.0.100
AUTO_SETUP_NET_STATIC_MASK=255.255.255.0
AUTO_SETUP_NET_STATIC_GATEWAY=192.168.0.1
AUTO_SETUP_NET_STATIC_DNS=9.9.9.9 149.112.112.112
##### Software options #####
# SSH server choice: 0=none/custom | -1=Dropbear | -2=OpenSSH
AUTO_SETUP_SSH_SERVER_INDEX=0

# SSH server pubkey
# - Public key(s) for "root" and "dietpi" users, which will be added to ~/.ssh/authorized_keys
# - Use the same setting multiple times for adding multiple keys.
# - See SOFTWARE_DISABLE_SSH_PASSWORD_LOGINS below for disabling SSH password logins.
#AUTO_SETUP_SSH_PUBKEY=ssh-ed25519 AAAAAAAA111111111111BBBBBBBBBBBB222222222222cccccccccccc333333333333 mySSHkey

On my host pc, I edited etc/network/interfaces to

iface eth0 inet static
 address 192.168.0.100
 netmask 255.255.255.0
 gateway 192.168.0.1
 dns-nameservers 192.168.0.1

also tried

iface eth0 inet static
 address 192.168.0.99
 netmask 255.255.255.0
 gateway 192.168.0.1
 dns-nameservers 192.168.0.1

also tried swapping nameservers on both configs above with

 dns-nameservers 9.9.9.9 149.112.112.112

still cant connect to ssh via PuTTy, returning connetion refused

When I completely remove the iface eth0 inet static block from my host pc, the ethernet adapter doesnt connect, it stays stuck on connecting and then shows failed to connect

What could be the problem?

Side note: If you use Linux, I strongly advise against Ethernet adapters with the RTL8153 REALTEK chipset - the most common.

I suspect this maybe causing problems itself, they are the most common but not out-of-box compatible with linux, I had to manually download drivers.

So you assigned the same IP address to both devices, this can not work. Also if your directly connect both devices with one cable don’t set a gateway, because their is no route to another network, you just have this 2 clients in the network and nothing else. Also you don’t need to set a DNS, because there is no route to the internet.

On the Neo, leave the values for gateway and DNS just blank.
On you PC, change the static ip to something else then 192.168.0.100 (but in the same range 192.168.0.X) and also remove the gateway and DNS values.
Reboot then both devices.

@Jappe

PC /etc/network/interfaces

iface enxc84d4422e3e4 inet static
 address 192.168.0.101
 netmask 255.255.255.0
 gateway
 dns-nameservers

NEO3 boot/dietpi.txt

# Set to "1" to convert DHCP leased network settings into static settings automatically on first boot.
AUTO_SETUP_DHCP_TO_STATIC=1
# Enter your static network details below, if applicable.
AUTO_SETUP_NET_USESTATIC=1
AUTO_SETUP_NET_STATIC_IP=192.168.0.100
AUTO_SETUP_NET_STATIC_MASK=255.255.255.0
AUTO_SETUP_NET_STATIC_GATEWAY=
AUTO_SETUP_NET_STATIC_DNS=

##### Software options #####
# SSH server choice: 0=none/custom | -1=Dropbear | -2=OpenSSH
AUTO_SETUP_SSH_SERVER_INDEX=-2

AUTO_SETUP_SSH_PUBKEY=ssh-ed25519 AAAAAAAA111111111111BBBBBBBBBBBB222222222222cccccccccccc333333333333 mySSHkey

reboot pc

sudo putty root@192.168.0.100 returns no route to host
sudo putty 192.168.0.100 also returns no route to host

nmap -sP 192.168.0.0/24

returns

Starting Nmap 7.80 ( https://nmap.org ) at 2024-01-30 09:08 GMT
Nmap scan report for 192.168.0.101
Host is up (0.00011s latency).
Nmap done: 256 IP addresses (1 host up) scanned in 7.60 seconds