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

LoveVPS: $7/month/2 CPU/2GB RAM/25GB space/1000GB browsing/KVM

LoveVPS是成立于2011年1月的主機商,僅提供VPS,有SSD VPS、KVM VPS、XE...

(MT)MediaTemple host lifetime discount code

Registration code for lifetime 20% discount: reta...

LAUNCH VPS: $5.95/month/2GB RAM/40GB SSD space/2TB bandwidth/KVM/Los Angeles

LAUNCH VPS, an American hosting provider, has goo...

NOCIX: $20/month/16GB memory/2TB hard disk/33TB traffic/5 IP/Kansas

NOCIX, owned by datashack.net, has its own comput...

Time4VPS: €11.94/year/512MB RAM/512GB storage/4TB bandwidth/OpenVZ/Lithuania

Time4VPS is affiliated to Interneto vizija (estab...