use*_*775 5 linux ssh user-accounts permissions centos-7
我们有堡垒服务器。我们应该有一些用户需要使用 proxyCammand 和私钥从本地通过堡垒 SSH 到 C。
我想创建只能从 Bastion 主机访问 ssh 的用户和组(通过 proxyCommand 进行)。他们也不需要读取文件。
我怎样才能做到这一点?有办法吗?
如果上述方法不可能,则另一种选择是仅对允许的文件具有读取访问权限,但仅对这些组具有读取访问权限的受限文件(操作系统默认)除外。
网络流量
您可以使用iptables
限制网络流量:
# Allow port 22 traffic to a specific IP/hostname for a specific user
iptables -A OUTPUT -p tcp --dport 22 -d allowed_host -m owner --uid-owner username -j ACCEPT
# Block all other outgoing port 22 (SSH) traffic
iptables -A OUTPUT -p tcp --dport 22 -d 0.0.0.0/0 -j REJECT
Run Code Online (Sandbox Code Playgroud)
文件系统访问
要限制文件系统访问,您可以使用文件系统权限
他们也不需要读取文件。
为了能够登录,他们需要能够读取一些文件:
要禁止普通用户进行读取访问,您可以从 root 拥有的文件中删除全局可读标志,或从 root 拥有的目录中删除全局可执行和全局可读标志:
# chmod o-r secret-file
# ls -l secret-file
-rw-r----- 1 root root 0 Mar 27 13:23 secret-file
# chmod o-rx secret-dir/
# ls -ld secret-dir/
drwxr-x--- 2 root root 64 Mar 27 13:24 secret-dir/
Run Code Online (Sandbox Code Playgroud)