基于 SSH 密钥限制访问

Nik*_*s R 3 unix authentication permissions ssh shell

假设我在远程服务器上有一个帐户storage,用户可以从中上传和下载数据。我手动将允许用户的 SSH 密钥添加到/home/storage/.ssh/authorized_keys. 现在,我有两个使用不同公共 SSH 密钥的用户:Watson 和 Sherlock。

如何确保 Watson 无法向 Sherlocks 私人画廊上传/下载?是否可以根据用于身份验证的 SSH 密钥定义文件/文件夹权限?

我想到了一个被设置为storage用户 shell 的受限 shell 程序。但是这个受限 shell 如何找出使用的 SSH 密钥呢?

dam*_*ois 6

您可以尝试使用文件command中的选项/home/storage/.ssh/authorized_keys和受限 shell,如下所示:

command="cd /home/storage/watson && rbash" ssh-rsa AAAAB3...2Z <- watson's public key
command="cd /home/storage/sherlock && rbash" ssh-rsa AAAAB4...R5 <- sherlock's public key
Run Code Online (Sandbox Code Playgroud)

现在,用户将在子目录中获得受限制的 shell,具体取决于使用的私钥。