Firstly, user boomclick's answer helped a lot with getting to this point. It's worth trying his answer first as this one has a bit more faffing.
When in the RPi and able to issue commands you're going to want to type in ip a
. You should have a few results, these are your networks. Look for one that stands out as ethernet such as eth0
. For me it was not this but rather enxb827eb5a927d
. I know it's odd one but it's likely due to my USB to ethernet adapter (ethernet port of laptop is broke). It stood out to me as the other choices were loopback and wlan0. Copy that name of the device (again mine being enxb827eb5a927d
) and then sudo nano /etc/network/interfaces
. When in here you can add networks at your will, for example I have a custom for CAN networks. The code I put in was the following:
allow-hotplug [name of device]
auto [name of device]
iface [name of device] inet static
address 169.x.x.x
That IP address is incomplete as you'll see. For your IP address refer to boomclick's answer for the best way to get it. After you're all done typing out your information Ctrl+X to exit, you'll be asked if you want to save so press Y then asked for a filename but we don't want it to change so hit Enter.
Now that file has been changed you could go ahead and reboot if you wanted to but I did make an additional change to be sure port 22 (SSH port) was open. sudo iptables -L
will list your ip table rules. As default you should have nothing there and and all of the policies should be in ACCEPT state. I added a rule that says accept any incoming connections to port 22, they would still have to enter passwords regardless so it's not as unsafe as it sounds. sudo iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
will do the job. If you list the iptables again you should see that rule.
Finally reboot, sudo reboot now
for all the changes to become effective. Give the RPi a minute to boot up then SSH in as you normally would but with your 169.x.x.x address. If you're prompted to accept a fingerprint accept and congratulations.