LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-19-2024, 05:07 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Rep: Reputation: 10
Post Different SSH settings for different users


Hello,
I have several users on the system, but I want each of them to have different SSH settings. Is this possible?

Thank you.
 
Old 02-19-2024, 07:18 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 938

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
sshd_config and ssh_config support conditional match blocks, condition can include usernames e.g. 'match user jason'.
 
Old 02-19-2024, 08:45 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,725

Rep: Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919
Without knowing what you mean by different settings it is not possible to say what you want to do is possible.
 
Old 02-19-2024, 12:20 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Usually, "ssh" stores per-user settings in a per-user directory ... within that user's "/home."

So, what exactly is your situation, and thus your question?
 
Old 02-28-2024, 01:11 AM   #5
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by michaelk View Post
Without knowing what you mean by different settings it is not possible to say what you want to do is possible.
Hello,
Thank you so much for your reply.
I have two users on the system. Jason and James. I want Jason to use port 22 and James to use port 23 to use SSH and settings such as ListenAddress, MaxAuthTries, MaxSessions, etc. are different for each user.
 
Old 02-28-2024, 01:34 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
that means you need to have two sshd processes, one of them is listening on port 22, with its own setup and another one on port 23.
https://serverfault.com/questions/28...tiple-port-ssh
But anyway you can find a lot of info about it on the net, we can only repeat those information.
 
Old 02-28-2024, 05:40 AM   #7
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by pan64 View Post
that means you need to have two sshd processes, one of them is listening on port 22, with its own setup and another one on port 23.
https://serverfault.com/questions/28...tiple-port-ssh
But anyway you can find a lot of info about it on the net, we can only repeat those information.
Hello,
Thank you so much for your reply.
Looks like Match has a lot of options.
Is the following configuration correct?
Code:
match user jason
PermitRootLogin no
MaxSessions 1
MaxAuthTries 2
PermitEmptyPasswords
LocalPort 22
 
Old 02-28-2024, 09:35 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,321
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by Jason.nix View Post
Is the following configuration correct?
No. You'll need to re-read the manual page for sshd_config about how Match works.

Then you might be able to work out some pattern with users and ports in the Match clause followed by AllowGroup or DenyGroup.

It's still not clear what problem you are trying to solve.
 
Old 02-28-2024, 05:12 PM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
I suspect that you don't actually need to use "different, and non-standard, ports."

This smells like an "XY Problem." Why don't you give us more information about your scenario and use-case?
 
Old 02-28-2024, 08:33 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,992

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
https://www.baeldung.com/linux/ssh-multiple-ports
 
Old 03-02-2024, 01:06 AM   #11
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by sundialsvcs View Post
I suspect that you don't actually need to use "different, and non-standard, ports."

This smells like an "XY Problem." Why don't you give us more information about your scenario and use-case?
Hello,
Thank you so much for your reply.
I have already explained it. Please see #5.

Last edited by Jason.nix; 03-02-2024 at 01:08 AM.
 
Old 03-02-2024, 01:09 AM   #12
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by jefro View Post
Hello,
Thank you so much for your reply.
Should I have two SSH daemons?
 
Old 03-02-2024, 01:18 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
Quote:
Originally Posted by Jason.nix View Post
Hello,
Thank you so much for your reply.
I have already explained it. Please see #5.
No that is not the explanation. The question was why do you want it? What problem do you want to solve by using two ports?
 
Old 03-07-2024, 01:52 PM   #14
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by pan64 View Post
No that is not the explanation. The question was why do you want it? What problem do you want to solve by using two ports?
Hello,
Thanks again.
I want to do this for two reasons:
1- I want to have Fail2Ban service for one port, but not for another.

2- When you install a program like GitLab, this program uses port 22 by default to clone through SSH. If you change the SSH port to another port, then you must define this new port through the gitlab_shell_ssh_port option in the GitLab settings. This causes problems for some users because they use port 22 by default to clone repositories. If having different ports, then one port can be used for system management and another port can be used for all users in the GitLab group.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Different users for different connections through SSH daghenningsorbo Linux - Networking 4 01-04-2011 04:46 AM
IceWM: Different Display settings for different users worm5252 Linux - Newbie 2 01-16-2010 07:45 AM
permission settings for different users..;P varewoolf Mandriva 1 06-05-2009 05:42 PM
permission settings for different users... varewoolf Linux - Security 2 06-05-2009 02:55 PM
how to set diff fetchmail settings for different users? deepugopi Linux - Server 0 10-24-2007 07:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration