我想在远程主机(例如 proxy.example.com)中创建一个用户,是否有像 git-shell 这样的受限登录 shell 用于仅代理 ssh 访问?
自己写!
restricted-shell.c
:
#include <stdio.h>
int main() {
printf("You are now connected to the proxy. Press enter to exit.\n");
scanf("*c");
exit(0);
}
这里是仅为socks5代理创建受限访问用户的代码。
#!/bin/bash
echo -n "Enter username: "
read usernamee;
cd /tmp/
useradd $usernamee -m -d /home/$usernamee -s /bin/rbash
passwd $usernamee
cd /home/$usernamee/
echo 'PATH=""' >> /home/$usernamee/.profile
chmod 555 /home/$usernamee/
chmod 444 .bash_logout .bashrc .profile
只需创建 shell 脚本并使其可执行
chmod +x shell.sh