Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
73
views
use setfacl to remove a users access to a directory?
So here is something I could not find any reference to, I have this user, user_A, I want to remove its access to this directory entirely /log/dirA As far as I understand, chmod is used to modify the access in this order user/group/others. Others is general and does not care who this is, just anyone...
So here is something I could not find any reference to, I have this user, user_A, I want to remove its access to this directory entirely /log/dirA
As far as I understand, chmod is used to modify the access in this order user/group/others.
Others is general and does not care who this is, just anyone other than the user, while not a member of group will be "other(s)", so I don't want to mess with other users access to this path, but I want to limit user_A from accessing it.
Does **setfacl** work for directories too? because I used this command, which I think should deny read/write/execute access of the mentioned Directory to the user_A, but the user is still able to cd into the mentioned dir. Does setfacl apply only to files??
Command:
setfacl -Rdm u:user_A:--- /log/dirA
ls -lhtr of the mentioned path:
rwxr-xr-x+ 3 Mainuser Mainuser 19 Apr 17 2018 dirA
getfacl /log/dirA :
# file: dirA/
# owner: Mainuser
# group: Mainuser
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:user_A:---
default:group::r-x
default:mask::r-x
default:other::r-x
Navid Taghavi
(25 rep)
May 19, 2025, 08:45 AM
• Last activity: May 19, 2025, 02:58 PM
83
votes
3
answers
74650
views
How to restrict an SSH user to only allow SSH-tunneling?
How can I restrict a user on the SSH server to allow them **only** the privileges for [SSH tunneling][1]? i.e. So they cannot run commands even if they log in via SSH. My Linux servers are Ubuntu 11.04 and OpenWrt. [1]: https://unix.stackexchange.com/questions/14274/vpn-like-solution-for-ssh-tunneli...
How can I restrict a user on the SSH server to allow them **only** the privileges for SSH tunneling ? i.e. So they cannot run commands even if they log in via SSH.
My Linux servers are Ubuntu 11.04 and OpenWrt.
LanceBaynes
(41465 rep)
Jun 3, 2011, 08:47 AM
• Last activity: Feb 4, 2025, 07:22 PM
0
votes
1
answers
191
views
How to lock down Ubuntu linux so that only the active user can log in
I am new to linux and interested in only allow in login via direct access to the machine (active user). I don't even want to be able to log in remotely myself. Can someone please point me in the right direction on how to do this? I am using Ubuntu.
I am new to linux and interested in only allow in login via direct access to the machine (active user). I don't even want to be able to log in remotely myself. Can someone please point me in the right direction on how to do this? I am using Ubuntu.
pac_2023
(13 rep)
Oct 28, 2023, 03:22 PM
• Last activity: Oct 28, 2023, 03:26 PM
1
votes
0
answers
153
views
Block Particular Command in Linux for Specific Users
I want to whitelist some of the commands for users. I am getting solution using LShell [Limited Shell][1] but I want to restrict subcommands as well. I want user to access `docker ps` and `docker logs` only. How can I achieve it via LShell? [1]: https://github.com/ghantoos/lshell
I want to whitelist some of the commands for users. I am getting solution using LShell Limited Shell but I want to restrict subcommands as well.
I want user to access
I want user to access
docker ps
and docker logs
only. How can I achieve it via LShell?
mhassaankhokhar
(13 rep)
Oct 17, 2023, 08:03 AM
• Last activity: Oct 17, 2023, 09:56 AM
43
votes
2
answers
31665
views
Do you need a shell for SCP?
I'm allowing a friend a local account on my machine, exclusively for SCP. Can I specify his account's shell as `/bin/true`, or in any other way limit the account, while still allowing SCP?
I'm allowing a friend a local account on my machine, exclusively for SCP. Can I specify his account's shell as
/bin/true
, or in any other way limit the account, while still allowing SCP?
user4518
Mar 21, 2011, 10:06 PM
• Last activity: Sep 28, 2023, 07:47 AM
0
votes
0
answers
192
views
Account unlock is not happening even after unlock_time
I want to lock user account after 3 failed attempts, I am following this [guide][1]. I am using Ubuntu 14.04 (for jumphost purposes only). However, the automatic unlock is not happening after 10 minutes. To unlock I have to manually execute the following command sudo pam_tally2 -u devops --reset [1]...
I want to lock user account after 3 failed attempts, I am following this guide . I am using Ubuntu 14.04 (for jumphost purposes only). However, the automatic unlock is not happening after 10 minutes. To unlock I have to manually execute the following command
sudo pam_tally2 -u devops --reset
rahuls_
(11 rep)
Sep 25, 2023, 05:15 AM
• Last activity: Sep 27, 2023, 06:55 AM
1
votes
2
answers
506
views
How to prevent other users from creating new SSH sessions?
When I work on Linux test server (Debian 11) I have root, and want block other users open new session to this server during my work. Is it possible?
When I work on Linux test server (Debian 11) I have root, and want block other users open new session to this server during my work.
Is it possible?
tuytuy20
(115 rep)
Mar 28, 2023, 07:43 AM
• Last activity: Mar 29, 2023, 11:19 AM
1
votes
2
answers
1555
views
Does /usr/sbin/nologin have any side effects?
Background: We have a policy in the company to deactivate the login possibility as much as possible, which is understandable. I am just wondering if there are any other side effects if you specify `/usr/sbin/nologin` as the login shell of an account? Apart from the login capability are there any oth...
Background: We have a policy in the company to deactivate the login possibility as much as possible, which is understandable.
I am just wondering if there are any other side effects if you specify
/usr/sbin/nologin
as the login shell of an account? Apart from the login capability are there any other capabilities or features which will be deactivated? Any other known side effects?
megloff
(429 rep)
Feb 25, 2021, 07:07 PM
• Last activity: Dec 30, 2022, 01:01 PM
1
votes
1
answers
410
views
Using sleep command in ssh authorized_key to prevent user's actions
I'm setting up an Ubuntu server to receive ssh connections from clients so I will then be able to connect back to their machine (reverse SSH tunneling). I searched for a way to prohibit any action from the client on the server, and I found different solutions, but none seems as simple as just config...
I'm setting up an Ubuntu server to receive ssh connections from clients so I will then be able to connect back to their machine (reverse SSH tunneling). I searched for a way to prohibit any action from the client on the server, and I found different solutions, but none seems as simple as just configuring the authorized_key of a specific client on the server by adding:
command="sleep x seconds"
Am I missing something important that would make that solution not a good one?
Joel Rivest
(13 rep)
Jan 11, 2022, 09:23 PM
• Last activity: Jan 12, 2022, 02:58 PM
2
votes
1
answers
2859
views
Restrict SFTP users to different directories
How can I restrict some users/groups to some directories? I mean different users, different directories. - What I have: Ubuntu 14. - Experience with Ubuntu: Just started. What I have tried: 1. I read [this page](https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-on-ubuntu-12-04)....
How can I restrict some users/groups to some directories? I mean different users, different directories.
- What I have: Ubuntu 14.
- Experience with Ubuntu: Just started.
What I have tried:
1. I read [this page](https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-on-ubuntu-12-04) . This was working till a bit extent, what the problem is that, the user can do things only in his folder/directory, which is read/write and edit, but the user can also go elsewhere, and open files and copy scripts from there, which can be risky as while having a game server on the VPS. He can't delete/edit or add files but can VIEW files other than his directory.
2. And, then [this page](http://www.krizna.com/ubuntu/setup-ftp-server-on-ubuntu-14-04-vsftpd/) . This worked fine, but the problem is, I couldn't find a way to add more users to different directories. Like, I could only add one user to directory which was specified in sshd_config file. There is only one directory which can be restricted for one group. I want it to be flexible, able to add different users to different directories... groups.
Here is what I'm talking about:
sshd_config
Subsystem sftp internal-sftp
Match group shooter
ChrootDirectory /home/shooter/shooter/mods
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
That shooter
group can only access that ChrootDirectory
. If I add different users to that group, they'll be able to view only that path. I want other users to view other directories, how is that possible?
Please help me, It's really important for me, as I've many game-servers to handle on a VPS, working with different developers.
Shikhar Baheti
(21 rep)
Sep 19, 2015, 01:06 PM
• Last activity: Nov 25, 2021, 06:00 PM
1
votes
0
answers
69
views
Restrict root to su local accounts
I know that root can modify any config file. As a best practice, I would like to disable the capacity for root to su on accounts which authenticates against NIS or Active Directory. As a best practice, I would like to allow root to su only on local accounts. *My* definition of a local account is any...
I know that root can modify any config file.
As a best practice, I would like to disable the capacity for root to su on accounts which authenticates against NIS or Active Directory.
As a best practice, I would like to allow root to su only on local accounts. *My* definition of a local account is any line with an id in /etc/passwd (because of the
+user::::::
for NIS access).
I guess it would involve modifying the pam config, but I'm not clear on the how.
Mat M
(143 rep)
Jun 22, 2021, 10:06 AM
4
votes
1
answers
3202
views
How to check if unix account has been created with "--disabled-login" and "---disabled-password"
In Linux distributions like RedHat you can create a user with options `--disabled-login` and `---disabled-password` (see man page for command `adduser` [link][1]). I wonder if it is possible to check for an administrator after user creation if the login and password is disabled for a given user? Exi...
In Linux distributions like RedHat you can create a user with options
--disabled-login
and ---disabled-password
(see man page for command adduser
link ).
I wonder if it is possible to check for an administrator after user creation if the login and password is disabled for a given user? Exists there any possibility?
megloff
(429 rep)
Feb 26, 2021, 08:39 AM
• Last activity: Feb 26, 2021, 02:52 PM
0
votes
2
answers
580
views
Accounts with no password - are these capable to be login?
When you install software on linux often users and groups get automatically created. I am wondering if during this user creation a "default" or "random" password will be set and if not if you still will be able to login through the console (assumption is that a shell entry got created in /etc/passwo...
When you install software on linux often users and groups get automatically created.
I am wondering if during this user creation a "default" or "random" password will be set and if not if you still will be able to login through the console (assumption is that a shell entry got created in /etc/password and it is not set to nologin). Normally when you call "adduser" you have to provide a password. How does this work for automatic created users through software installations?
megloff
(429 rep)
Feb 25, 2021, 07:14 PM
• Last activity: Feb 25, 2021, 09:11 PM
0
votes
2
answers
483
views
Is it possible to prevent users to modify printer options in CUPS?
A small family setup... I have a color printer, and a Linux computer, with CUPS installed. I wan to allow the kids to print, but only in draft mode, and only in greyscale. With CUPS I prevented the kids' account from accessing the printer. Then I set up a second printer, for the same hardware printe...
A small family setup...
I have a color printer, and a Linux computer, with CUPS installed. I wan to allow the kids to print, but only in draft mode, and only in greyscale.
With CUPS I prevented the kids' account from accessing the printer. Then I set up a second printer, for the same hardware printer, but with different default options (draft and greyscale), and allowed the kids to access this new printer.
It works, when they print the default options for this new printer are indeed draft and greyscale. But they are just that, default options. They can change it.
Is there a way to prevent users from changing the options of a printer ?
ChennyStar
(1969 rep)
Feb 18, 2021, 10:05 AM
• Last activity: Feb 21, 2021, 04:42 PM
57
votes
6
answers
68490
views
How do I completely disable an account?
How do I completely disable an account? `passwd -l` will not allow anyone to log into an account using a password but you can still log in via private/public keys. How would I disable the account completely? As a quickfix I renamed the file to `authorized_keys_lockme`. Is there another way?
How do I completely disable an account?
passwd -l
will not allow anyone to log into an account using a password but you can still log in via private/public keys. How would I disable the account completely? As a quickfix I renamed the file to authorized_keys_lockme
. Is there another way?
user4069
Feb 20, 2011, 02:13 AM
• Last activity: Sep 29, 2020, 04:48 AM
0
votes
1
answers
270
views
How to restrict a local user to a jail directory in linux?
I have searched on google for restrict a user to a specific directory but mostly appeared about ssh user, ftp user and etc that not local user. How do we do that for local user?
I have searched on google for restrict a user to a specific directory but mostly appeared about ssh user, ftp user and etc that not local user.
How do we do that for local user?
Zozzizzez
(137 rep)
Sep 25, 2020, 10:53 AM
• Last activity: Sep 25, 2020, 11:11 AM
0
votes
0
answers
44
views
How to limit user to only cat & exit commands?
I would like to limit a user to only two commands: `cat` and `exit`. I've tried to edit `visudo` but it does not work. My OS version is CentOS 8.
I would like to limit a user to only two commands:
cat
and exit
.
I've tried to edit visudo
but it does not work.
My OS version is CentOS 8.
kdm.J
(11 rep)
Sep 1, 2020, 08:57 AM
• Last activity: Sep 2, 2020, 05:13 AM
26
votes
3
answers
44939
views
Can a command be executed over ssh with a nologin user?
If a user has `loginShell=/sbin/nologin` is it still possible to ssh user@machine [command] assuming that the user has proper ssh keys in its home directory that can be used to authenticate? My goal is to keep the user as a nologin, but still able to execute commands on a few other machines on the n...
If a user has
loginShell=/sbin/nologin
is it still possible to
ssh user@machine [command]
assuming that the user has proper ssh keys in its home directory that can be used to authenticate?
My goal is to keep the user as a nologin, but still able to execute commands on a few other machines on the network (similar to its use through 'sudo -u'), and am wondering if this is a reasonable course.
Centimane
(4520 rep)
Feb 10, 2015, 02:32 PM
• Last activity: Aug 6, 2020, 12:36 AM
0
votes
1
answers
747
views
Restrict some commands for user/group using sudoers (visudo)
I want to create group and want to allow the group to run all available commands except few commands. Can you please help me configure sudoers for the same. I checked but only found how to allow some commands. But I want to restrict some commands and allow remaining all. Thanks
I want to create group and want to allow the group to run all available commands except few commands. Can you please help me configure sudoers for the same.
I checked but only found how to allow some commands. But I want to restrict some commands and allow remaining all.
Thanks
Navi
(93 rep)
Jun 13, 2020, 05:35 PM
• Last activity: Jun 13, 2020, 06:33 PM
0
votes
1
answers
997
views
Ubuntu: Pointing an SFTP user to its working directory without listing other user's directory
I am working on configuring an SFTP server on Ubuntu Server 18.04. I want to create SFTP accounts that point directly to their working directory without listing others. For example if the real working directory on the server is `/sftpdir1/sftpdir2/user1`, the user should see it as `/` and not `/user...
I am working on configuring an SFTP server on Ubuntu Server 18.04. I want to create SFTP accounts that point directly to their working directory without listing others. For example if the real working directory on the server is
where I can upload and download files.
Update: why not setting chrootdirectory in
/sftpdir1/sftpdir2/user1
, the user should see it as /
and not /user1
like when using chrootdirectory
: when I login via FileZilla I should find as shown in the image below 
/etc/ssh/sshd_config
If I have more then on user assigned to the same group, so having the same chrootdirectory
, any user among will see others' working directory. Or by logging in I don't want the user to see others' dir nor the tree of his/her own working directory: just find /
like shown in the image.
fadwa dhifi
(9 rep)
Jun 4, 2020, 10:50 AM
• Last activity: Jun 4, 2020, 06:39 PM
Showing page 1 of 20 total questions