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

Disable intractive SSH depending on connection origin

· 52CE 我爱测

Scenario: Same users can connect from two different network segments to a ssh host. But they should not be able to use interactive ssh session when connecting from one (it's actually long-distance tunnels), only chrooted sftp sho…

问题原文

原帖链接 · Swift · CC BY-SA 4.0

Scenario: Same users can connect from two different network segments to a ssh host. But they should not be able to use interactive ssh session when connecting from one (it's actually long-distance tunnels), only chrooted sftp should be allowed.

How can it be achieved? Is this achievable by sshd's settings? Or by tcp wrapper (libwrap) + sshd?

已采纳解答

原帖链接 · diya · CC BY-SA 4.0

You can use the Match directive at the bottom of your sshd_config configuration file to override global settings based on, among others, the Address users connect from.

That allows you to set a plethora of specific settings differently for specific users/groups/clients.

# /etc/ssh/sshd_config
# ... 
# your current global config
#
# Enable the internal sftp server

Subsystem sftp internal-sftp

# ... 

# Override for users connecting from the 192.0.2.0/24 subnet
# They're only allowed to use sftp to their %h home directory

Match Address 192.0.2.0/24    
  ForceCommand internal-sftp 
  ChrootDirectory %h 

See this Q&A for background on the internal-sftp server.

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

资料来源与适用范围

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

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

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