Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1366  / 2 Years ago, wed, may 18, 2022, 11:06:42

I have written a script to add chrooted sFTP users.



The useradd command is:



sudo useradd -Ng sftponly -ms /bin/false "$USER"


Did it work?



groups $USER
$USER : sftponly


Yes it did. Great!



Then I take a look at /etc/group and there is no $USER in sftponly. I try logging in and out (shouldn't need to - I am not $USER) and nothing changes. (for $USER == yoko):



ftp:x:114:
sftponly:x:1003:george,john,paul,ringo
incron:x:115:


Why am I seeing $USER in the correct group when using groups, but not in /etc/group?


More From » users

 Answers
3

You shall not use useradd, but use adduser instead. However, if you insist on using useradd, here is what you should do:



sudo useradd -Ng sftponly -G sftponly -ms /bin/false "$USER"


The -g option only changes the /etc/passwd file, making "sftponly" the primary (login) group ID of the user. The -G option modifies /etc/groups.


[#30406] Thursday, May 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
overine

Total Points: 20
Total Questions: 109
Total Answers: 98

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
overine questions
Tue, Jul 12, 22, 00:27, 2 Years ago
Wed, Jan 11, 23, 02:15, 1 Year ago
Tue, Aug 10, 21, 01:39, 3 Years ago
;