Since this question is off-topic I moved it to Super User. But I was unable to delete it.
Here is the new location.
Here is the original question:
I'm trying to connect to a headless server via my laptop; they share a wired link via a Linksys wireless router ("Linksys EA6350") and TP-Link ethernet switch. I'm running Arch Linux on both machines, using a pretty default Systemd setup with dhcpcd for the network configuration.
I recently experienced the following error when trying to ssh to the server:
$ ssh -v -v -F /dev/null myserver
OpenSSH_7.7p1, OpenSSL 1.1.0h 27 Mar 2018
debug1: Reading configuration data /dev/null
debug2: resolving "myserver" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to myserver [fe80::9cd8:b045:5974:c5cf] port 22.
debug1: connect to address fe80::9cd8:b045:5974:c5cf port 22: Invalid argument
ssh: connect to host myserver port 22: Invalid argument
Running the same with strace
shows the error comes from connect
:
connect(3, {sa_family=AF_INET6, sin6_port=htons(22), inet_pton(AF_INET6, "fe80::9cd8:b045:5974:c5cf", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EINVAL (Invalid argument)
Usually I have a local named
forwarding DNS queries but the error persists when I go back to using the router's DNS server directly:
$ sudo cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
The error is intermittent: every few minutes I am able to connect successfully. When I can connect successfully, I see that connect
is using an IPv4 address:
connect(3, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("192.168.1.149")}, 16) = 0
However, the host
command shows the same IPv4 address whether the connection is working or broken:
$ host myserver
myserver has address 192.168.1.149
After reading this question I thought to specify the interface manually (ssh -v -v -F /dev/null -B en0 myserver
). This eliminates the error when it occurs, but it is not a permanent solution for me and it doesn't explain why the error suddenly appeared.