VPS添加SSH帐号

有了VPS之后只有一个SSH帐号未免太浪费了,以下是如何新添加一个受限帐户的方法。
查看系统安装的shells:

cat /etc/shells

如果没有“/bin/rbash”的话,要把“/bin/rbash”加入到/etc/shells文件里:

echo "/bin/rbash" >> /etc/shells

添加一份新用户:

useradd -s /bin/rbash -g nobody newuser

为新用户设定密码:

passwd newuser

输入两遍新密码后,建立用户成功。

修改新用户的.bash_profile:

vim /home/newuser/.bash_profile

将文件修改为:

export PATH=/home/newuser

至此,这个帐号就可以登录SSH而不能运行任何命令了。
-EOF-

《VPS添加SSH帐号》有2个想法

评论已关闭。