0

I want to disable all ssh connection from both IPv4 and IPv6 except certain IPs.

I can set /etc/hosts.deny to deny all IPv4 ssh connection:

sshd: ALL

How to apply to IPv6?

I tried below, and fail:

sshd: [*]

and

sshd: [ALL]

My sshd server version: PKIX-SSH 12.1, OpenSSH_8.0p1, OpenSSL 1.0.2g-fips 1 Mar 2016

And PKIX is configured with --with-tcp-wrappers

1 Answers1

1

If you want to "block" all IPv6 connections to your device you can simply not listen on IPv6.

So you can configure sshd_config to listen only on IPv4. ListenAddress IPv4:Port, example: ListenAddress 192.168.2.1:22

or

Define a IPv4 only hostname for your hosts

/etc/hosts
192.168.2.1 myhost
/etc/ssh/sshd_config
ListenAddress myhost:22
BitsOfNix
  • 5,057
  • 2
  • 25
  • 34
  • What I want to do is to disable all IPv6, but I want to let user to add white list. – Yu-Ting Chen Jul 29 '19 at 07:28
  • that does not make sense. If you want to disable IPv6 across the system then edit the question accordingly. I do not understand what you mean by "let user to add to white list". Once ipv6 is disbale system wide, you cannot use IPv6 any longer. This is valid for both incoming and outgoing connections. – BitsOfNix Jul 29 '19 at 07:40