I have dnsmasq configured on a DNS/DHCP server, which is set up so that the domain name mycompany.com
is automatically appended to the hostname of each device connected over DHCP. e.g. the computer with the hostname derek
will be assigned the FQDN derek.mycompany.com
. This is working as expected for the other devices connected to the network (one is able to ssh into them using their long hostname), however the majority of them are Macs and have automatically configured network settings.
The issue: I have a Raspberry Pi with Raspbian installed on it (let's say the IP address is 192.168.1.3
and its short hostname is rpi
) that I'm trying to get set up so that I can SSH into it. It's connected to the network over wifi and I'd like for it to have a static IP and also be able to assign a FQDN to it (i.e. rpi.mycompany.com
). To this end I've configured dnsmasq to identify it by its hardware address and to assign it a domain and IP. However after trying a lot of different configurations on both the rpi and the dns server, I keep getting the ssh: connect to host ... port 22: Connection refused
error.
This is what I have set up:
/etc/network/interfaces
on the pi:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
/etc/resolv.conf
on the pi:
domain mycompany.com
search mycompany.com
nameserver <ip address of dns server>
/etc/dnsmasq.d/hosts.conf
on the DNS/DHCP server:
dhcp-host=<mac address of the rpi>,rpi,192.168.1.3
Here are some facts for troubleshooting purposes:
- When I run
sudo service ssh status
, it says that sshd is running ok. - I haven't touched
/etc/ssh/sshd_config
, i.e.Port 22
,PasswordAuthentication yes
, and is set in it. - I am able to ping the machine from another network device, both by its IP address, short hostname, and long hostname.
- I can ping external addresses/domains (e.g.
google.com
) from the machine (which is why I didn't include/etc/wpa_supplicant/wpa_supplicant.conf
) - The pi is assigned the correct IP address from what I can see in the
ifconfig
output, as well as the correct long hostname from thehostname -A
.
But no matter what I do I can't seem to ssh in.
One thing I did notice was that at some point, I did manage to ssh in, and shortly after I attempted to scp
over my public key to use pubkey authentication instead, and I got the following error message:
ssh: connect to host 192.168.1.3 port 22: Connection refused
lost connection
And right after that I was suddenly unable to ssh in again, getting the same Connection refused
message above.
What am I doing wrong? Is it something to do with scp or is that just a fluke?
ssh localhost
and login successfully? – Fred Jan 25 '15 at 11:31