Beginner's Tutorial: Adding Multiple SSH Low-Privilege Accounts to Linux VPS

Beginner's Tutorial: Adding Multiple SSH Low-Privilege Accounts to Linux VPS

View the shells installed on the system:

cat /etc/shells

If there is no "/bin/rbash", add "/bin/rbash" to the /etc/shells file:

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

Add user tutorial:

1. Add a Linux user and grant the user a nologin shell permission.

useradd username -s /sbin/nologin

2. Set the user password.

passwd username

3. If you need to create this type of account frequently, create a script to facilitate your operation.

After connecting to the vps with root privileges via ssh terminal, enter:

vi ssh.sh
After editing a sh file, press the i key to enter the editing mode.
Then copy the following content (right-click the mouse in the terminal to copy)

!/bin/bash

useradd $1 -s /bin/false
echo $1:$2 | chpasswd

Then press esc and enter :wq to save and exit edit mode.
In this way, you can easily create an ssh proxy account by entering the following command:

bash ssh.sh username password

Username and password are the account and corresponding password you want to set, which can be replaced.
In the above script, $1 is the corresponding username, and $2 is the corresponding password.
Where did the $0 go? That's ssh.sh.
$1, $2, and $0 are parameter markers used in bash scripts, indicating the number of parameters respectively.

Restricting users to single sign-on SSH

First let /etc/pam.d/sshd connect to pam_limits.so
Add the following line to /etc/pam.d/sshd
session required pam_limits.so
Then add the following line to /etc/security/limits.conf to implement single sign-on for user wind through SSH. The subsequent login session will fail.
wind – maxlogins 1
Then restart the server and restart the related service options. No need to remind me then.
[[email protected] ~]# reboot

References:
http://www.vps55.com/post/109.html
http://tweetyf.org/2013/04/setup_low_level_ssh.html
http://www.deepvps.com/add-proxy-ssh-account-on-vps.html
http://www.msits.com/archives/2204.html

<<:  Web3k: $3/month/20GB storage/200GB traffic/unlimited cPanel accounts

>>:  HostQala: $4.95/month/1 core/512M/10G/100G/1 IP/OpenVZ

Recommend

LOCVPS 2GB RAM SSD Hard Drive Japan Osaka Xen VPS Review

Details: LOCVPS: 64 yuan/month/2GB memory/40GB SS...

1GServers: $39/month/E3-1240v3/16GB memory/1TB hard drive/20TB bandwidth/Phoenix

1GServers, an American hosting provider, was esta...

SiberDC: $8/month/8GB RAM/100GB SSD space/unlimited traffic/1Gbps/KVM/US

SiberDC, a Turkish merchant with a tax number (61...

CorgiTech 1GB RAM SSD Hard Drive VMware Japan Simple Review

Details: CorgiTech: $7/month/1GB RAM/30GB SSD/3TB...

mrVM: $2/month/512MB memory/50GB space/1TB traffic/KVM/Dallas

mrVM, founded in early 2017, now has 2 special kv...

Tier: $55/month/L5520/24GB memory/2TB space/20TB traffic/Dallas

Tier, a long-established American hosting provide...

site5 Halloween and Black Friday promotion codes

Site5 hasn't launched a discount code for a l...

Aulerion 512MB RAM San Jose KVM VPS Review

1. Introduction to Aulerion VPS: Aulerion: You ge...