OpenSSH only one SSH session allowed per user at a time

Last updated on February 10th, 2023 at 09:54 am.

Limiting the number of SSH sessions per user

If you want to set up only one SSH session allowed per user at a time in OpenSSH, this post will show you how to do it.

Edit the SSH configuration file ( /etc/ssh/sshd_config ). Use vim or nano.

sudo nano /etc/ssh/sshd_config

Add the following line to your server SSH config file. If there is another occurrence of MaxSessions , delete it or comment it out:

MaxSessions 1

Save the file and restart the SSH server. Using Nano, do CTRL + X, press Y then enter to save and close.

Restart SSH

# Ubuntu / Debian:
sudo service ssh restart

# CentOS / RHEL:
sudo systemctl restart ssh

# Fedora:
sudo systemctl restart ssh

Benefits of limiting SSH sessions

  •     Improved security: By limiting concurrent SSH sessions, your server will be secured from targeted simultaneous attacks coordinated by the same attacker.
  •     Resource Management: There is only one or limited users, so, no one is hogging resources from others due to large number of requests by multiple users.
  •     Better Monitoring: Keeping track of SSH activity is much easier, making it faster to detect any server intrusions. It is also possible to set up login notification, so that when someone logs into your server, you will get an email alert.

Comment Here

Need WordPress help? Linux Server help? Talk to us.

  • We are your own WordPress customer service.
  • We set up Linux servers and install or migrate WordPress. Learn more here.
  • We support WooCommerce too.
  • Check out our WordPress customer support plans here or contact us below .

If you have any questions regarding WordPress support, Linux server support or any of our services, feel free to reach out or read more on our services page.

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!