What worked for me was a combination of the answers from Nicole Finnie and Ciro Santilli along with some answers from elsewhere.
Setting up the pi
We will need to do two things: activate ssh on the pi, and configure the pi to use a static ip.
Activating ssh
Add a file called ssh
in the boot partition of the sd card (not the /boot
folder in the root partition). This is well documented other places.
Static ip
Open /etc/dhcpcd.conf
on the pi's SD-card, and uncomment the example for a static ip (starts around line 40). Set the addresses to
# Example static IP configuration:
interface eth0
static ip_address=10.42.0.182/24
static routers=10.42.0.1
static domain_name_servers=10.42.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
Setting up your laptop
First, make sure you have networkmanager
(with GUI) installed on your laptop. Then, make sure dnsmasq
is not running as a service:
systemctl status dnsmasq
If this command prints that the service is stopped, then you're good.
Next we have to config networkmanager
. Open /etc/NetworkManager/NetworkManager.conf
and add the following two lines at the top:
[main]
DNS=dnsmasq
Then reboot. This step might not be necessary. It might be sufficient to restart the NetworkManager
service. Now go to the NetworkManager
GUI (usually accessed by an icon in the corner of the screen) and choose Edit Connections...
In the window that pops up, click the +
icon to create a new connection. Choose Ethernet
as the type and press Create...
. Go to the IPv4 Settings
tab and select the method Shared to other computers
. Give the connection a good name and save.
Connect the Raspberry Pi and make sure your laptop is using your new connection as its ethernet connection. If it is, your pi should now have an ip given to it by your pc. You can find this by first running ifconfig
. This should give you several blocks of text, one for each network interface. You're interested in the one that is something like enp0s25
or eth0
. It should have a line that reads something similar to
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
look at the broadcast address (in this case 10.42.0.255
). If it is different than mine, power off the pi and put the SD card back in your laptop to change the static ip_address
to something where the first three numbers are the same as in your broadcast address. Also change the static routers
and the first of the domain_name_servers
to your laptop's inet
address. Power the pi back on and connect it. Run ifconfig
again to see that the addresses have not changed.
ssh into the pi
ssh pi@10.42.0.182
If you get connection refused
, the pi isn't running an ssh
server. If you get host unreachable
, I'm sorry.
Hope this helps someone!