大网数据广告活动
服务器运维问答

sshd_config AllowUsers and IPv6

· 52CE 我爱测

Have two servers communicating via ssh and crontab, a "master" and a "slave". Only the master can connect (execute command) on the slave. Authentication was done automatically (IPv4) thanks to master's ~/.ssh/id_rsa.pub added to …

问题原文

原帖链接 · Déjà vu · CC BY-SA 3.0

Have two servers communicating via ssh and crontab, a "master" and a "slave". Only the master can connect (execute command) on the slave.

Authentication was done automatically (IPv4) thanks to

  • master's ~/.ssh/id_rsa.pub added to slave's ~/.ssh/authorized_keys
  • slave's sshd_config having AllowUsers [email omitted]

It was working fine until IPv6 was added

  • both master and slave have IPv6 enabled
  • both servers have had DNS reverse setup for both protocols
  • sshd_config changed to AllowUsers [email omitted]

and was hoping sshd slave does a reverse lookup of the incoming IPv6 IP (to get myhost.tld) but auth.log shows

User me from 2103:cc11::...:fe93:4a10 not allowed because not listed in AllowUsers

I'd have two questions

  1. does sshd perform an IPv6 reverse lookup to find out if the host matches? (if yes, there is another problem)
  2. what is the correct way to add an IPv6 address hard-coded in AllowUsers? It seems me@[2103:cc11::...:fe93:4a10] doesn't work. (edit works without the [])

已采纳解答

原帖链接 · William Sandin · CC BY-SA 3.0

Have a look at the UseDNS directive.

"UseDNS Specifies whether sshd(8) should look up the remote host name, and to check that the resolved hostname for the remote IP address maps back to the very same IP address.

If this option is set to no (the default) then only addresses and not host names may be used in ~/.ssh/authorized_keys from and sshd_config Match Host directives."

As a side-note you could always configure the client to force IPv4 for connection to that particular host in your ssh_config. I mostly used AllowUsers to match usernames, if you want to match on hostnames and IP you might want to have a look at using TCP wrapper instead.

See: https://www.akadia.com/services/ssh_tcp_wrapper.html

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-12-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。