[cxd@0x5c0f ~][0]$ useradd --help
用法:useradd [选项] 登录名
useradd -D
useradd -D [选项]选项:
-h, --help 显示此帮助信息并退出
-k, --skel SKEL_DIR 使用此目录作为骨架目录
The skeleton directory, which contains files and directories to be copied in the user\'s home directory,
when the home directory is created by useradd.
This option is only valid if the -m (or --create-home) option is specified.
If this option is not set, the skeleton directory is defined by the SKEL variable in
/etc/default/useradd or, by default, /etc/skel.
-m, --create-home 创建用户的主目录
-o, --non-unique 允许使用重复的 UID 创建用户
This option is only valid in combination with the -u option.
-s, --shell SHELL 新账户的登录 shell
-u, --uid UID 新账户的用户 ID
# 上述操作完成后,还需要创建一个chroot目录$> mkdir /sftpdir
$> echo hello > /sftpdir/readme.md
# 注意目录属主必须为root,属组可以不是,权限不能超过755 $> chown root.root /sftpdir
$> chmod 755 /sftpdir
# 重启sshd服务(重载也可以)$> systemctl reload sshd
## 登陆测试$> sftp -i /home/webapp/.ssh/id_rsa webapp@127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:hQkISJWcE+gHf1WAT2bIWSwiAJRD81Bv3wZd+1vZOuU.
ECDSA key fingerprint is MD5:0e:e5:1a:c7:6c:97:fb:48:95:d2:c9:86:bb:d0:7d:91.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1'(ECDSA) to the list of known hosts.
Connected to 127.0.0.1.
sftp> ls -l
-rw-r--r-- 1006 Dec 8 06:31 readme.md
sftp> pwdRemote working directory: /
sftp>