For details on the setup environment, refer to Set up raspbian buster on Raspberry Pi 4.
When I ssh connect to Raspberry Pi, it takes time to connect.
The default is IPv6 connection → IPv4 connection, and it took time for the IPv6 connection to time out. (Maybe I made a mistake during setup)
I wondered if it was a problem on the Raspberry Pi side because it is slow to connect from Windows Powershell or other Linux.
Debug information can be displayed by executing it with the -v option when sshing. Here, you can see that you are connecting to Raspberry Pi from Windows, and after failing to connect like an IPv6 address due to a timeout, you are connecting with IPv4.
$ ssh -v Username@Machine name
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1:Connecting to machine name[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx] port 22.
debug1: connect to address xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx port 22: Connection timed out
debug1:Connecting to machine name[yyy.yyy.yyy.yyy] port 22.
debug1: Connection established.
Change the Raspberry Pi settings.
$ sudo vi /etc/sysctl.conf
Add the following to sysctl.conf.
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Reflect changes in sysctl.conf.
$ sudo sysctl -p
Confirm that there is no item called inet6 with the following command.
$ ip a
Close the ssh connection once.
$ exit
Connect with ssh again and check.
$ ssh -v Username@Machine name
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1:Connecting to machine name[yyy.yyy.yyy.yyy] port 22.
debug1: Connection established.
The above disables IPv6 on all interfaces. If you want to disable only a specific interface, add the following items to /etc/sysctl.conf. Below is an example of disabling only eth0.
net.ipv6.conf.eth0.disable_ipv6 = 1
Recommended Posts