Linux/UNIX: Configure OpenSSH To Listen On an IPv6 Address

How do I enable OpenSSH SSH server to listen on an IPv6 address under Linux or UNIX operating systems?

The ListenAddress directive in sshd_config file specifies the local addresses sshd should listen on. The syntax is as follows:

ListenAddress host
ListenAddress IPv4_addr:port
ListenAddress [IPv6_addr]:port

Edit /etc/ssh/sshd_config file, enter:
# vi /etc/ssh/sshd_config
To bind sshd to every IPv4 and IPv6 address on your server, enter:

ListenAddress ::

To bind sshd to every IPv6 2607:f0d0:1002:11::2 address on your server, enter:

ListenAddress [2607:f0d0:1002:11::2]

To bind sshd to every IPv6 2607:f0d0:1002:11::2 address and port 311 on your server, enter:

ListenAddress [2607:f0d0:1002:11::2]:311

From the sshd_man page:

If port is not specified, sshd will listen on the address and all prior Port options specified. The default is to listen on all local addresses. Multiple ListenAddress options are permitted. Additionally, any Port options must precede this option for non port qualified addresses.

Save and close the file. If you changed the port, update your iptables or pf firewall configuration. Finally, reload sshd:
# service sshd reload

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Jan Jan 31, 2011 @ 18:31

    You forgot to mention the sshd_config parameter AddressFamily any/inet/inet6 and accompanying commandline parameters -4 and -6 to further finegrain sshd usage.

  • pushapdant Jun 3, 2013 @ 6:34

    I am trying to setup ntpd for ipv6. /etc/ntd.conf is not liking ipv6 local link addresses at its server address. Even i tried using %interface but no luck. Have you tried including ipv6 local link address in your sshd_config ? Let me know if it works for you.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum