Method for users to change Samba password
I have a Samba server for about 5 users (security = user) and I want a way for these users to change their passwords without my involvement so I have the following idea. Is this secure? Is there a better (as in more simple) approach. We used to have SWAT for this but no more.
On server: create restricted user (/bin/rbash + PATH to single directory)
$ sudo adduser --shell /bin/rbash pwchange
$ cat /etc/passwd
pwchange:x:1001:1001:pwchange,,,:/home/pwchange:/bin/rbash
$ sudo vi /home/pwchange/.bashrc
Add:
export PATH=/usr/local/pwchange
$ sudo ln -s /usr/bin/smbpasswd /usr/local/pwchange/smbpasswd
This idea here is that only the sambpasswd command can be run by
the pwchange user. The unix accounts for the Samba users do
not have passwords (i.e. log on via these accounts not allowed).
The samba users would only be able to use this restricted account for self service Samba password changes ... no exploring the server!
Client: Change Samba password via Terminal or Putty (Windows)
user1@A3700:~$ ssh pwchange@192.168.1.14
pwchange@V220:~$ smbpasswd -U user1
Old SMB password:
New SMB password:
Retype new SMB password:
Password changed for user user1
samba
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a Samba server for about 5 users (security = user) and I want a way for these users to change their passwords without my involvement so I have the following idea. Is this secure? Is there a better (as in more simple) approach. We used to have SWAT for this but no more.
On server: create restricted user (/bin/rbash + PATH to single directory)
$ sudo adduser --shell /bin/rbash pwchange
$ cat /etc/passwd
pwchange:x:1001:1001:pwchange,,,:/home/pwchange:/bin/rbash
$ sudo vi /home/pwchange/.bashrc
Add:
export PATH=/usr/local/pwchange
$ sudo ln -s /usr/bin/smbpasswd /usr/local/pwchange/smbpasswd
This idea here is that only the sambpasswd command can be run by
the pwchange user. The unix accounts for the Samba users do
not have passwords (i.e. log on via these accounts not allowed).
The samba users would only be able to use this restricted account for self service Samba password changes ... no exploring the server!
Client: Change Samba password via Terminal or Putty (Windows)
user1@A3700:~$ ssh pwchange@192.168.1.14
pwchange@V220:~$ smbpasswd -U user1
Old SMB password:
New SMB password:
Retype new SMB password:
Password changed for user user1
samba
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
But I thoughtsmbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?
– George Udosen
Dec 17 '17 at 5:07
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12
add a comment |
I have a Samba server for about 5 users (security = user) and I want a way for these users to change their passwords without my involvement so I have the following idea. Is this secure? Is there a better (as in more simple) approach. We used to have SWAT for this but no more.
On server: create restricted user (/bin/rbash + PATH to single directory)
$ sudo adduser --shell /bin/rbash pwchange
$ cat /etc/passwd
pwchange:x:1001:1001:pwchange,,,:/home/pwchange:/bin/rbash
$ sudo vi /home/pwchange/.bashrc
Add:
export PATH=/usr/local/pwchange
$ sudo ln -s /usr/bin/smbpasswd /usr/local/pwchange/smbpasswd
This idea here is that only the sambpasswd command can be run by
the pwchange user. The unix accounts for the Samba users do
not have passwords (i.e. log on via these accounts not allowed).
The samba users would only be able to use this restricted account for self service Samba password changes ... no exploring the server!
Client: Change Samba password via Terminal or Putty (Windows)
user1@A3700:~$ ssh pwchange@192.168.1.14
pwchange@V220:~$ smbpasswd -U user1
Old SMB password:
New SMB password:
Retype new SMB password:
Password changed for user user1
samba
I have a Samba server for about 5 users (security = user) and I want a way for these users to change their passwords without my involvement so I have the following idea. Is this secure? Is there a better (as in more simple) approach. We used to have SWAT for this but no more.
On server: create restricted user (/bin/rbash + PATH to single directory)
$ sudo adduser --shell /bin/rbash pwchange
$ cat /etc/passwd
pwchange:x:1001:1001:pwchange,,,:/home/pwchange:/bin/rbash
$ sudo vi /home/pwchange/.bashrc
Add:
export PATH=/usr/local/pwchange
$ sudo ln -s /usr/bin/smbpasswd /usr/local/pwchange/smbpasswd
This idea here is that only the sambpasswd command can be run by
the pwchange user. The unix accounts for the Samba users do
not have passwords (i.e. log on via these accounts not allowed).
The samba users would only be able to use this restricted account for self service Samba password changes ... no exploring the server!
Client: Change Samba password via Terminal or Putty (Windows)
user1@A3700:~$ ssh pwchange@192.168.1.14
pwchange@V220:~$ smbpasswd -U user1
Old SMB password:
New SMB password:
Retype new SMB password:
Password changed for user user1
samba
samba
asked Feb 21 '16 at 3:39
brucehohl
46113
46113
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 5 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
But I thoughtsmbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?
– George Udosen
Dec 17 '17 at 5:07
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12
add a comment |
But I thoughtsmbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?
– George Udosen
Dec 17 '17 at 5:07
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12
But I thought
smbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?– George Udosen
Dec 17 '17 at 5:07
But I thought
smbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?– George Udosen
Dec 17 '17 at 5:07
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12
add a comment |
1 Answer
1
active
oldest
votes
Giving them all access to the same dummy account doesn't sound smart. Even if you lock it down to have access to nothing BUT smbpasswd
they could still change eachother's passwords. And there's always possibility of a malicious privilege escalation attack.
Essentially what it sounds like you want is to allow them to run ONLY the smbpasswd
command from their own user account while still having an equivalent to a nologin
account.
This can be accomplished with the use of the "ForceCommand" option in your sshd_config.
Try this:
Grant each user with a Samba account membership to the same group. For our example let's say "sambaOnly":
#From Root
groupadd sambaOnly
usermod -a -G sambaOnly Joe
Next, we want to change our sshd_config file to have the following:
#From Root
cat << EOF >> /etc/ssh/sshd_config
Match Group sambaOnly
ForceCommand smbpasswd
EOF
Presto. From my understanding (and brief testing) this means when they login via SSH they will automatically have the smbpasswd
command run and they will be prompted accordingly. They will never get the chance to have shell access. After the command completes they are automatically disconnected, again never getting a chance to have shell access.
I am not 100% sure this removes all access to the machine remotely. For example, if you are running a different SSH server on the same machine that doesn't ForceCommand
them, then they could login via that depending on its access control config.
Also, if they have the opportunity for physical access to a terminal they can login.
However, I think for most situations this is fairly strong access control.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264682%2fmethod-for-users-to-change-samba-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Giving them all access to the same dummy account doesn't sound smart. Even if you lock it down to have access to nothing BUT smbpasswd
they could still change eachother's passwords. And there's always possibility of a malicious privilege escalation attack.
Essentially what it sounds like you want is to allow them to run ONLY the smbpasswd
command from their own user account while still having an equivalent to a nologin
account.
This can be accomplished with the use of the "ForceCommand" option in your sshd_config.
Try this:
Grant each user with a Samba account membership to the same group. For our example let's say "sambaOnly":
#From Root
groupadd sambaOnly
usermod -a -G sambaOnly Joe
Next, we want to change our sshd_config file to have the following:
#From Root
cat << EOF >> /etc/ssh/sshd_config
Match Group sambaOnly
ForceCommand smbpasswd
EOF
Presto. From my understanding (and brief testing) this means when they login via SSH they will automatically have the smbpasswd
command run and they will be prompted accordingly. They will never get the chance to have shell access. After the command completes they are automatically disconnected, again never getting a chance to have shell access.
I am not 100% sure this removes all access to the machine remotely. For example, if you are running a different SSH server on the same machine that doesn't ForceCommand
them, then they could login via that depending on its access control config.
Also, if they have the opportunity for physical access to a terminal they can login.
However, I think for most situations this is fairly strong access control.
add a comment |
Giving them all access to the same dummy account doesn't sound smart. Even if you lock it down to have access to nothing BUT smbpasswd
they could still change eachother's passwords. And there's always possibility of a malicious privilege escalation attack.
Essentially what it sounds like you want is to allow them to run ONLY the smbpasswd
command from their own user account while still having an equivalent to a nologin
account.
This can be accomplished with the use of the "ForceCommand" option in your sshd_config.
Try this:
Grant each user with a Samba account membership to the same group. For our example let's say "sambaOnly":
#From Root
groupadd sambaOnly
usermod -a -G sambaOnly Joe
Next, we want to change our sshd_config file to have the following:
#From Root
cat << EOF >> /etc/ssh/sshd_config
Match Group sambaOnly
ForceCommand smbpasswd
EOF
Presto. From my understanding (and brief testing) this means when they login via SSH they will automatically have the smbpasswd
command run and they will be prompted accordingly. They will never get the chance to have shell access. After the command completes they are automatically disconnected, again never getting a chance to have shell access.
I am not 100% sure this removes all access to the machine remotely. For example, if you are running a different SSH server on the same machine that doesn't ForceCommand
them, then they could login via that depending on its access control config.
Also, if they have the opportunity for physical access to a terminal they can login.
However, I think for most situations this is fairly strong access control.
add a comment |
Giving them all access to the same dummy account doesn't sound smart. Even if you lock it down to have access to nothing BUT smbpasswd
they could still change eachother's passwords. And there's always possibility of a malicious privilege escalation attack.
Essentially what it sounds like you want is to allow them to run ONLY the smbpasswd
command from their own user account while still having an equivalent to a nologin
account.
This can be accomplished with the use of the "ForceCommand" option in your sshd_config.
Try this:
Grant each user with a Samba account membership to the same group. For our example let's say "sambaOnly":
#From Root
groupadd sambaOnly
usermod -a -G sambaOnly Joe
Next, we want to change our sshd_config file to have the following:
#From Root
cat << EOF >> /etc/ssh/sshd_config
Match Group sambaOnly
ForceCommand smbpasswd
EOF
Presto. From my understanding (and brief testing) this means when they login via SSH they will automatically have the smbpasswd
command run and they will be prompted accordingly. They will never get the chance to have shell access. After the command completes they are automatically disconnected, again never getting a chance to have shell access.
I am not 100% sure this removes all access to the machine remotely. For example, if you are running a different SSH server on the same machine that doesn't ForceCommand
them, then they could login via that depending on its access control config.
Also, if they have the opportunity for physical access to a terminal they can login.
However, I think for most situations this is fairly strong access control.
Giving them all access to the same dummy account doesn't sound smart. Even if you lock it down to have access to nothing BUT smbpasswd
they could still change eachother's passwords. And there's always possibility of a malicious privilege escalation attack.
Essentially what it sounds like you want is to allow them to run ONLY the smbpasswd
command from their own user account while still having an equivalent to a nologin
account.
This can be accomplished with the use of the "ForceCommand" option in your sshd_config.
Try this:
Grant each user with a Samba account membership to the same group. For our example let's say "sambaOnly":
#From Root
groupadd sambaOnly
usermod -a -G sambaOnly Joe
Next, we want to change our sshd_config file to have the following:
#From Root
cat << EOF >> /etc/ssh/sshd_config
Match Group sambaOnly
ForceCommand smbpasswd
EOF
Presto. From my understanding (and brief testing) this means when they login via SSH they will automatically have the smbpasswd
command run and they will be prompted accordingly. They will never get the chance to have shell access. After the command completes they are automatically disconnected, again never getting a chance to have shell access.
I am not 100% sure this removes all access to the machine remotely. For example, if you are running a different SSH server on the same machine that doesn't ForceCommand
them, then they could login via that depending on its access control config.
Also, if they have the opportunity for physical access to a terminal they can login.
However, I think for most situations this is fairly strong access control.
edited Nov 28 '18 at 2:02
answered Nov 28 '18 at 1:54
Geraden
7115
7115
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264682%2fmethod-for-users-to-change-samba-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
But I thought
smbpasswd
was meant for users and admin alike to change their passwords... Is that what you want?– George Udosen
Dec 17 '17 at 5:07
In this case the Unix accounts of the users do not have passwords, therefore, user1 cannot log on as user1@192.168.1.14. The Samba server was setup as "security = user" and file restrictions were set in smb.conf. Users were not allowed a Unix logon as the underlying Unix file permissions were more permissive than the combination of Samba and Unix file permissions (Unix extended ACLs were not used.)
– brucehohl
Dec 18 '17 at 10:41
At my college we had a self serving portal which users can auth using id and sms verification, and in the background we issued the smbpasswd command
– Rabin
Oct 25 '18 at 5:12