这个方法的副作用就是只有root才能使用sftp!

创建用户组,创建用户,设置密码:
复制内容到剪贴板代码:
groupadd SSHTunnel
useradd -g SSHTunnel -s /bin/bash -d /home/tunnel TunnelUser1
passwd TunnelUser1
设置sftp权限:
复制内容到剪贴板代码:
chmod 700 /usr/lib/openssh/sftp-server
在/etc/ssh/sshd_config内添加:
复制内容到剪贴板代码:
Match Group SSHTunnel
        AllowTcpForwarding yes
        ForceCommand sh /home/tunnel/tunnelshell.sh
下载设置登陆脚本:
复制内容到剪贴板代码:
wget https://chencp.info/tunnelshell.sh --no-check-certificate -O  /home/tunnel/tunnelshell.sh
ln -s  /home/tunnel/tunnelshell.sh  /home/tunnel/.profile
最后重启sshd:
复制内容到剪贴板代码:
/etc/init.d/ssh restart
这样就可以了,同时用户登陆后还支持passwd命令修改密码。

再添加用户则:
复制内容到剪贴板代码:
useradd -g SSHTunnel -s /bin/bash -d /home/tunnel <用户名>
passwd <用户名>
技术文章 | 评论(0) | 引用(0) | 阅读(460)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写