linux 添加受限用户 SSH登录

[root@liugh ~]# useradd --help
Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the new user account
                                home directory
  -c, --comment COMMENT         set the GECOS field for the new user account
  -d, --home-dir HOME_DIR       home directory for the new user account
  -D, --defaults                print or save modified default useradd
                                configuration
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP for the new user account
  -G, --groups GROUPS           list of supplementary groups for the new
                                user account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           specify an alternative skel directory
  -K, --key KEY=VALUE           overrides /etc/login.defs defaults
  -m, --create-home             create home directory for the new user
                                account
  -l,                       do not add user to lastlog database file
  -M,                       do not create user's home directory(overrides /etc/login.defs)
  -r,                       create system account
  -o, --non-unique              allow create user with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new user
                                account
  -s, --shell SHELL             the login shell for the new user account
  -u, --uid UID                 force use the UID for the new user account
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping

实质还是Linux账户控制那一套东西。



1、登录 VPS

在终端应用程序上输入以下命令:

SSH root@94.249.184.93

记得将 "94.249.184.93" 替换成你 VPS 的 IP 地址。

2、创建一个用户组

输入以下命令:

groupadd internetfreedom

你可以将 "internetfreedom" 替换成任意名字。

3、创建受限用户

输入以下命令:

useradd -d /home/freenutsdotcom -m -g internetfreedom -s /bin/false freenutsdotcom

以上命令将会在 "internetfreedom" 创建一个新的 SSH 用户 "freenutsdotcom",该用户只能使用 SSH 代理,不能登录你的 VPS 帐户。

4、为新用户设置密码

输入以下命令:

passwd freenutsdotcom

然后,为该用户设置任意密码 (例如 "123456")。

完了之后,你就可以把该用户名和密码分享给朋友,他们也就可以通过以下命令使用你的 SSH 代理:

ssh -N -D 7070 freenutsdotcom@94.249.184.93

记得把 "freenutsdotcom" 替换成你新建的用户名,把 "94.249.184.93" 替换成你 VPS 的 IP 地址。


http://www.epooll.com/archives/642/





vps增加ssh账号用来代理上网,即开通没有shell权限的ssh帐号的方法:(说明:此账号没有ssh登陆权限)

——————————————-

useradd -M -s /sbin/nologin -n username//说明,username表示开通的ssh账号
passwd 用户名//修改用户密码

userdel -r 用户名//删除用户

——————————————-

操作实例演示:

比如要添加用户名为 ssh001 的账号,账号密码为:123 可以进行如下操作:

首先以root身份登录vps
[root@220.181.111.147]# useradd -M -s /sbin/nologin -nssh001
[root@220.181.111.147]# passwdssh001

Changing password for userssh001
New UNIX password:123(实际操作中,这里的密码是不会显示的)
Retype new UNIX password:123(实际操作中,这里的密码是不会显示的)
passwd: all authenication tokens updated successfully.


http://sologuy.bizhijidi.com/175/




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值