I have a device that I need to connect to over SSH. The device is connected to my workstation via a direct ethernet connection. I'm attempting to assign the connected device an IP address somehow that I can SSH to, however all of the guides I'm finding have the user configure the IP from whatever device they're working with (namely Raspberry Pi's and so on). This is not something I can do with this device as I've no physical interface to work with.

I've been recommended to setup a DHCP server on my workstation so it would take care of this for me, however I've no idea how to configure it and none of the guides I have followed have been helpful. With that approach, I seem to have been able to bind an IP to the interface the device is connected on, however SSHing to that IP just brings me back to my own machine.

So my main question is: How do I assign an IP address to a device directly connected to my computer via ethernet cable without having any kind of access to the device (no interface, keyboard, monitor, etc). If the answer is to set up a DHCP server on my machine, how do I properly configure this and get an IP I can SSH to?

For reference, I am using Ubuntu 16.04 with OpenSSH installed. The device is also running some flavor of Linux and has SSH software installed, but again there's no way to interact with it except through SSH. I also do not have access to my router, so plugging the device in there and letting the router do the work is not an option.


The link given by @steve is appropriate, but if you want to try something simple first just to see what the device does you can use dnsmasq, which is a simple dns and dhcp server. Install with sudo apt-get install dnsmasq. If this also enables and starts the server you need to stop and disable it.

If, say, your device is on your ethernet interface eth2, and you have done sudo ifconfig eth2 to set the interface ip address, then you can try:

sudo dnsmasq -d -C /dev/null --port=0 --domain=localdomain --interface=eth2 --dhcp-range=,,99h

which sets up a dhcp server in debug mode (-d), not as a daemon, with dns (port=0) able to offer addresses in the range .2 to .10, and to hold the same ones for 99hours.

If your device broadcasts a request to discover an address you should see it, and the reply (offer):

dnsmasq-dhcp: DHCPDISCOVER(eth2) 94:71:ac:ff:85:9d 
dnsmasq-dhcp: DHCPOFFER(eth2) 94:71:ac:ff:85:9d 

The numbers are the ip address assigned and the device's mac address. You may need to reset or power on the device if it has given up broadcasting. The device might reply to ping and then you can try to ssh too. You can interrupt the dnsmasq once the address has been offered in this test and put the options in the standard dnsmasq config file and so on.

You may also usefully run sudo tcpdump -i eth2 to see what packets pass.

| improve this answer | |

So I know this is late but in your case and in the case of many other small creators who want to connect ssh to devices like a raspberry pi there is a reasonable safe and easy way which doesn't need additional hardware (except for the ssh node hardware(raspberri pi for example), ethernet cable and the ssh client(other computer most likely).

it also doesn't really need you to set up things or configure things that may block or hinder future things.

in short we use the ssh servers MAC address instead of their IP address the MAC address can be seen as some kind of a hardware(instead of software) ip address speciffic to a hardware ethernet of wifi card. unlike a -non static- IP address a Mac address should not change.

I did this with a pine A64+ but in this example I will call it a raspberry pi(pi) since those are more used(both will work the same) so first make sure ssh is enabled in the os of your pi, I expect those who come here will have it installed.

next connect the cable to your pc and turn on the pi(allow it to start so give it some time, just as long as you feel like if you have never measured) do not yet connect the pi to the ethernet cable.

now on the client pc who will control the other one start wireshark, if it isn't installed you can easly download and install it since it is supported on basically all mayor and less known but still known operating systems.

select to capture the ethernet signal(the right one if you have more). you literally can see Ethernet in the capture options and even on the startup screen.

next connect the ethernet cable to the pi or disconnect and reconnect it if it was already connected.

now you will get a lot of data but you most likely will see 2 MAC adresses which you didn't see before you connected the pi, those MAC adresses will show up in the source row and they will spam a lot the first few seconds after you connect the pi.

now in your ssh command or program try those 2 MAC adresses in stead of a ip and use the default port 20 unless you changed the port. one of the 2 will reject your connection(most likely) and the other one will connect thi one will be your pi and you will directly be in your ssh ready to log in.

now to save some work you should copy and past the pi's MAC address into a text document, the Mac address should never change unless you manually change/spoof it. if both MAC adresses allow ssh, log in to both and you can use basic commands or just their feedback to determine if they are the right one based on os, filesystem, name, etc. this however will not happen unless you have a ssh server running on both devices.

if you don't like wireshark than you can also find the devices MAC address using ifconfig on the device you want to control(this will need input and a monitor on the device for a while. and you can also try to look into the arp tables on your controller pc when they are not and when they are connected, however this might be harder if you don't know what you are doing.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.