if [ $# -eq 0 ];
then
echo "create sftp user and homedir"
echo "arg1 username, arg2 password"
exit
fi
uid="$1"
upwd="$2"
USER_COUNT=`cat /etc/passwd | grep ^${uid}: -c`
if [ $USER_COUNT -ne 1 ]
then
useradd ${uid} -M -g group_sftp -d /sftp/${uid}/upload -s /sbin/nologin
echo '${upwd}' | passwd $uid --stdin
mkdir /sftp/${uid}
mkdir /sftp/${uid}/upload
chown root:root /sftp/${uid}
chown -R ${uid} /sftp/${uid}/upload
chmod -R 700 /sftp/${uid}/upload
cat >> /etc/ssh/sshd_config << EOF
Match User ${uid}
ChrootDirectory /sftp/${uid}
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
EOF
service sshd restart
echo "${uid} user created. sftp root is /sftp/${uid}/"
else
echo "user exits"
fi
#
linux ami sftp
最新推荐文章于 2024-08-30 14:11:28 发布