我正在运行Debian Linux。 我想有一个用户帐户,只能通过SSH进行连接,而不需要命令提示符。
例如以下内容可以工作(从远程计算机):
ssh -D1234 user@myhost
但不会出现命令提示符。
使用像/ bin / false或/ sbin / nologin这样的shell是太严格了,因为它甚至不允许用户login。只允许“退出”或Ctrl + D命令的shell将完成这项工作。
我知道类似的可能只允许SFTP,但我找不到相当于TCP转发。
谢谢
这听起来像你正在寻找-N选项:
-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
像这样:
ssh -D 8080 -N [email protected]
也有一些兴趣可能是-f选项:
-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm.
如果你想限制什么入站连接可以:
authorized_keys文件中设置一个自定义命令(假设你使用的是ssh密钥) 你使用的命令/ shell取决于你想要的。 例如:
/bin/cat会保持连接打开,但是什么都不做 rssh将允许您自定义可用的操作 bash可以在限制模式下运行( rbash ),它只允许你在configuration的PATH运行命令。 这不是万无一失的,但它是值得的。 我不确定这是否会。 我有一个集群,我希望人们在前端工作,但他们不允许在计算节点上。 所有人在所有计算机上都有帐户,但是, /etc/profile的节点有以下几行:
if test "$TERM" != "linux" && test "$USER" != "root" ;then echo "" echo -e "\\033[0;34m=======================================================================\\033[0;39m" echo "" echo -e "\\033[0;31m Login to this host is allowed for administrator only.\\033[0;39m" echo -e " Please use \\033[0;34mqueue\\033[0;39m to submit your jobs instead" echo -e " or \\033[0;34m132.187.71.6\\033[0;39m or \\033[0;34m132.187.71.7\\033[0;39m to login into cluster front-end." echo "" echo -e "\\033[0;34m=======================================================================\\033[0;39m" echo "" exit fi
具有$TERM的部分检查login是直接的( 即用ssh )还是通过排队系统。 最后一个是允许的。 如果你想要一个特定的用户被允许login,你可以添加到if-statment && test "$USER" != "someuser"