我正在将 Debian 服务器迁移到 Ubuntu 16.04。Debian 服务器上的其中一个软件包scponly充当 shell,仅允许 ssh 连接用于 scp 目的(不登录或运行scp二进制文件以外的任何东西)。可在此处找到详细信息。这个软件包已经通过至少 2 次物理服务器升级,无数次操作系统升级,在 Debian 上出现,大概可以追溯到 2007 年左右。
scponly不在任何 16.04 存储库中,也未在启动板上编译。虽然我完全有能力从源代码安装它,但这让我想知道在过去 10 多年里是否有更好的方法来配置 ssh 以仅允许 scp 命令,这对 Ubuntu 16.04 更友好,而不是基于昏暗和遥远的过去。有任何想法吗?
ste*_*ver 15
根据这个serverfault.com回答Allow SCP but not actual login using SSH,目前支持的一种方法是 using rssh,它可以从universe存储库中获得:
sudo apt-add-repository universe
sudo apt-get install rssh
Run Code Online (Sandbox Code Playgroud)
要允许 SCP,您必须取消注释文件中的相应行/etc/rssh.conf(以及您希望启用的任何其他协议):
allowscp
#allowsftp
#allowcvs
#allowrdist
#allowrsync
#allowsvnserve
Run Code Online (Sandbox Code Playgroud)
那么这只是将用户的登录shell更改为rssh shell的问题,例如
sudo chsh -s /usr/bin/rssh steeldriver
Run Code Online (Sandbox Code Playgroud)
然后您可以测试 SCP 是否有效,例如
$ scp steeldriver@localhost:~/Pictures/somefile.png ./
steeldriver@localhost's password:
somefile.png 100% 34KB 33.7KB/s 00:00
$
Run Code Online (Sandbox Code Playgroud)
但是 SSH 应该会失败并显示拒绝消息,例如
$ ssh steeldriver@localhost
steeldriver@localhost's password:
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-88-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Wed Jul 6 16:23:47 2016 from localhost
This account is restricted by rssh.
Allowed commands: scp
If you believe this is in error, please contact your system administrator.
Connection to localhost closed.
Run Code Online (Sandbox Code Playgroud)
请注意,似乎没有必要添加/usr/bin/rssh到 /etc/shells 中允许的登录 shell 列表中
| 归档时间: |
|
| 查看次数: |
12170 次 |
| 最近记录: |