date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,669,048,418,000 |
I'm trying to configure a fetchmail. Before I deal with the syntax of fetchmailrc ( I discovered that the level of bugginess of a problem is synergistic with the number of different aspects of the problem that I do not understand, so one new thing at a time ), I decided to pass all the options via commandline.
I got tired of entering the password for each test so I wanted to pass it in the script. I couldn't find something like --pass as a commandline option for fetchmail so I thought maybe echo the password to fetchmail ala:
echo "dohadeer"| fetchmail --all -p pop3 -k pop.gmail.com --ssl -d0 --user [email protected]
I dismissed it and googled "fetchmail password commandline" and got several hits which claimed the above technique worked! But when I tried it I get the error:
fetchmail: can't find a password for [email protected]@pop.gmail.com.
I can figure out workarounds for the original problem, but I can't figure out why this approach doesn't work. Obviously there is something I don't understand about Linux and want to figure out.
|
The reason for the given error message is that fetchmail has its standard input not attached to a terminal, but a pipe.
man fetchmail | less -Ip 'user authentication step failed'
# from:
# http://opensource.apple.com/source/fetchmail/fetchmail-33/fetchmail/fetchmail.c
...
if (!isatty(0)) // <-- tests if stdin is a terminal (added)
{
fprintf(stderr,
GT_("fetchmail: can't find a password for %s@%s.\n"),
ctl->remotename, ctl->server.pollname);
return(PS_AUTHFAIL);
} else {
...
You may, however, try the following script hack to let fetchmailrun in a pseudo terminal.
(sleep 0.3; echo "dohadeer") |
( script -q /dev/null fetchmail --all -p pop3 -k pop.gmail.com --ssl -d0 --user [email protected] )
| Why can't I echo the password to fetchmail? |
1,669,048,418,000 |
I have three systems, and I want to have them doing backups between them periodically. The two of them, have Debian Wheezy installed and the other one has Ubuntu 12.04 installed. Only the Ubuntu has a GUI environment, while the other two are CLI only.
For the backups I want to use rsync via ssh, with the Debian systems being the destinations of the backups. I have the commands sorted out and the ssh keys properly generated and copied among the systems, but since the Debian systems do not have a graphical environment installed, the ssh-agent is not run automatically. Therefore, whenever I try to ssh to the Debian systems, I get a prompt for the passphrase.
Is there a way to skip the prompt? From what I understand I cannot use the ssh-agent, when I only have the CLI. I am looking for a solution that works even after a restart without me doing anything after reboot.
Thanks in advance.
|
I would create a separate specific passwordless SSH key for this purpose. On the server side, you can set limits to what that key can be used for and where it can connect from, so that even if someone gets hold of the key, they would still not be able to use it to do something malicious.
The way to limit the key is to edit the authorized_keys file on the server side, and add some configuration to it. Here's an example:
from="10.1.2.3",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="/path/to/rsync" ssh-dss AA....[rest of key]
| Automatic login via ssh (no GUI environment installed / no ssh-agent available)? |
1,669,048,418,000 |
So,
When I try to login with my username and password (in tty), and insert a wrong password, I need to wait around 5 seconds for the system to tell me that the password is wrong.
Why the validating process is taking that long?
GNU/Linux disto: Archlinux.
|
Adding a little bit of historical perspective, the idea of sleeping after a bad password is not just found in PAM-based systems. It's very old. For eaxmple in the 4.4BSD login source you'll find this tasty fragment:
/* we allow 10 tries, but after 3 we start backing off */
if (++cnt > 3) {
if (cnt >= 10) {
badlogin(username);
sleepexit(1);
}
sleep((u_int)((cnt - 3) * 5));
}
so the first 3 failures are free, the next 7 have increasing delays (5 seconds, 10 seconds, 15 seconds...) and after 10 it does a sleepexit(1) which is a 5 second delay followed by an exit(1).
The sleeps are just an annoyance when you're typing a password on the console, but they're important when the input is coming from a remote user who might be automating the process.
The sleepexit after 10 failures deserves special explanation. After login exits, getty just prints another login prompt and starts the cycle again. So why sleep and exit instead of just sleeping? Because when this feature was introduced, login over dialup was common. (Note for people who never used a modem before 1995: I said login over dialup, not PPP or other packet-based protocol over dialup. You'd dial a number in a terminal emulator and get a login prompt.)
In the dialup world, anybody could just dial your number and start throwing passwords at it, so the login process exited after a few bad passwords, causing the modem connection to terminate, forcing them to redial before they could try more passwords. The same principle applies to ssh today (configuration option MaxAuthTries) but it was more effective in the old days, because dialing a modem was quite a bit slower than a TCP handshake.
| Login into a GNU/Linux distribution is taking too long |
1,669,048,418,000 |
Is there some kind of pwd generator for Linux that has a nice GUI and options like this one for Windows? I know that there is pwgen, but as far as I know it does not support mouse/keyboard entropy and it does not have any kind of front end GUI's... or does it?
|
Well, pwgen for Linux uses /dev/urandom (which is a fine cryptographic-quality random source). The Linux kernel accumulates entropy internally (it used to use mouse and keyboard movements, though recent versions have discarded this in favor of better entropy sources); it does a better job of it than a program that merely asks the user to wriggle the mouse.
An better one is APG that optionally uses /dev/random and asks for keyboard input (in principle, to randomize even more, though isn't actually useful on modern operating systems that collect entropy internally).
If you want a GUI, there's jpasswordgen in Java, so it works everywhere.
IMHO, I don't see the usefulness of using a GUI for this. The goal is to get passwords, and pwgen/apg can even generate nicely formatted lists of passwords.
| Something like pwgen-win for linux? |
1,669,048,418,000 |
I know for the same user name, we can do:
ssh-keygen
ssh-copy-id
to skip entering the password.
However, in my understanding, this is for remote and client servers both having the same user name.
However, the user name in the remote server didn't exist in my client server. How can I do ssh-copy-id here to skip entering the password?
ex: I need to do as follows:
mark@client:~$ ssh jack@ip_of_remote_server
|
There's no obligation to have the same user name on the remote machine.
Your username on the local machine is jack
Your username on the remote machine is john
you can append john@<remote IP> to all your commands.
So:
ssh-keygen. This is a local operation, it remains unchanged.
ssh-copy-id john@<remote IP>. This copies the private key of jack@local to the authorized keys of john@remote.
ssh john@remote will log you in.
Note on default values
When you run ssh remote, the program defaults to using the username of your local user. So it's really equivalent to ssh jack@remote
| How to ssh without password and using a different user name? |
1,669,048,418,000 |
How I am supposed to use systemd-ask-password-console.service? My aim is to trigger a password prompt and ask for input on some terminal.
Currently I am trying it like this:
Start systemd-ask-password-console.service.
Ensure that no other password agent is running: ps aux | grep ask
Ensure that no other password agent is to be started: systemctl status systemd-ask*
Execute systemd-ask-password --no-tty "Password:" to trigger the password agent.
Step 3 is waiting for an agent to return the password and finally times out. In the meantime the request can be seen within /run/systemd/ask-password/.
systemctl status systemd-ask-password-console.service shows:
● systemd-ask-password-console.service - Dispatch Password Requests to Console
Loaded: loaded (/lib/systemd/system/systemd-ask-password-console.service; static; vendor preset:
Active: active (running) since Fri 2018-05-11 16:46:43 CEST; 6min ago
Docs: man:systemd-ask-password-console.service(8)
Main PID: 392 (systemd-tty-ask)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/systemd-ask-password-console.service
├─392 /bin/systemd-tty-ask-password-agent --watch --console
└─393 /bin/systemd-tty-ask-password-agent --watch --console=/dev/tty1
May 11 16:46:43 debian systemd[1]: Started Dispatch Password Requests to Console.
I would expect that the running agent processes the request and that it will use some terminal (e.g. tty1) to ask for the password.
What I am doing wrong?
|
systemd-ask-password-console.service is a system service that queries the user for system passwords (such as hard disk encryption keys and SSL certificate passphrases) on the console. It is intended to be used during boot to ensure proper handling of passwords necessary for boot. systemd-ask-password-wall.service is a system service that informs all logged in users for system passwords via wall(1). It is intended to be used after boot to ensure that users are properly notified.
https://www.freedesktop.org/software/systemd/man/systemd-ask-password-console.service.html
because it is not possible to reliably read from the console while another process (sh or login) is already reading from the console. More specifically, user input will be passed to only one process, and you cannot guess which process that will be.
| How to use `systemd-ask-password-console.service` |
1,669,048,418,000 |
I have a file in server A which I am able to do transfer to server B using scp.
I need to do this through a cron entry. server B has a password.
How do I perform this?
|
Don't use password authentication. Use ssh keypairs.
Karthik@A $: ssh-keygen #keep the passphrase empty
Karthik@A $: ssh-copy-id B #enter your B password
#^ this will copy your public key to Karthik@B:.ssh/authorized_keys
From then on, you should be able to ssh from A to B (and by extension, scp from A to B) without a password.
| How do I scp a file from server A to server B from cron? |
1,669,048,418,000 |
Inside one of my scripts, I created an user based on a directory arrangement on another machine.
The thing is that this user, created without a password, behaves just as he had one : he has sudo rights but I simply can't sudo because it asks for a password that doesn't exist. I know I could simply passwd him as root, but the devised system has to work without intervention from local root privileged users.
I also cannot passwd as the user in question since passwd asks me for the same inexistant password.
I suppose that it is intended behavior, but then what is the eventual default password and what can I do to circumvent this ?
EDIT : Here is what the script does :
1: it rsyncs the home directories of the users who should be created or updated in /opt/sshgw/home (sshgw means ssh gateway) from our ssh gateway machine
2: it removes all authorized keys for every user of the machine running the script
3: it removes every user from the wheel group and performs usermod -L (I am not the author of the script and I do not really know why he locks the account, but whatever.) Though keep in mind that at this point only existing users are modified.
4: It creates users if they have been retrieved from the sshgw and they are not present on the local machine, then, if specified, they are added the wheel group. It then adds their public keys to their proper home directories and finally performs usermod -U.
The user's entry in /etc/passwd is normal.
Upon calling passwd, the users gets asked his current password (which can not exist for a user who has just been created without a password, mind you) in this fashion :
[splatpope@monitor sshgw]$ passwd
Changing password for user splatpope.
Changing password for splatpope.
(current) UNIX password:
I guess the culprit is usermod -U.
|
A user is created by default as a locked account. The field that should contain the password hash in /etc/shadow will contain !!. When an account is locked, that account is available to root only (root can su but logins aren't allowed). If you 'unlock' the account which simply removes the !! you will be allowed to change the password.
[root@test ~]# su - test
[test@test ~]$ passwd
Changing password for user test.
Changing password for test.
(current) UNIX password:
[test@test ~]$ exit
logout
[root@test ~]# passwd -u test
Unlocking password for user test.
passwd: Warning: unlocked password would be empty.
passwd: Unsafe operation (use -f to force)
[root@test ~]# passwd -u test -f
Unlocking password for user test.
passwd: Success
[root@test ~]# su - test
[test@test ~]$ passwd
Changing password for user test.
New password:
| User created without a password behaves as if he had one |
1,669,048,418,000 |
I have a debian box that I connect to via SSH. I have removed the password from the users root, and my personal account using the instructions here, and set up a public/private key pair so I can log in, but only if I have the private key.
I recently ran cat /etc/passwd in order to see what other users where on the system, and got a fair list back. So, how can I determine the password status for each user so that if I make the box public to the wider world (via ssh only), there are no other users that someone could use to authenticate with?
|
Probably you should look at sshd configuration.
There is an option to deny password authentication:
PasswordAuthentication no
and you can create a list of users that are allowed to connect via ssh:
AllowUsers cgoddard
| Determining the Password Status of a User |
1,669,048,418,000 |
http://codahale.com/how-to-safely-store-a-password/
with what does OpenBSD store the password by default?
They say bcrypt is way more secure then hashing. I googled' it and obsd supports bcrypt, but does it use it by default?
Thank you!
|
From: http://www.openbsd.org/papers/bcrypt-paper.pdf
We have implemented bcrypt and deployed it as part
of the OpenBSD operating system. Bcrypt has been
the default password scheme since OpenBSD 2.1
| Does OpenBSD use bcrypt by default? |
1,669,048,418,000 |
I've changed my password to X and the shadow file has changed to:
ahmad:$1$oYINSKjP$eCkCtJV/2dXerAD57WQPj/:15425:0:99999:7:::
I see the encrypted X as $1$oYINSKjP$eCkCtJV/2dXerAD57WQPj/. How can I retrieve the encrypted X without changing the password? openssl or any other command to use?
|
Your password isn't encrypted. It is hashed.
A salted MD5 hash has been generated and written to /etc/shadow. You cannot retrieve original value.
The original value X has been hashed in this format: $id$salt$encrypted - id == 1 stands for MD5 (see NOTES on manpage of crypt(3))
| Encrypt word X to /etc/shadow encryption |
1,669,048,418,000 |
Confession. I know little about linux, am an XP refugee, and try to do things I don't understand. I generally find it easier to find out how to do things, than to understand whether I should be doing them in the first place.
I am using Mint 18. At my then level of understanding, it seemed that having the same password for sudo and my user account was less strong than having different ones. I now understand that root is disabled by default on Ubuntu/Mint intentionally.
After searching on the web, I did something to enable a separate password, not sure what, my notes aren't clear around that date, but I edited a file. Needless to say I can't remember exactly what search I was using to get me back to those instructions.
The result was that I was able to set a separate password for root, which probably means I enabled the account. Now when I sudo from the terminal, it requires the root password. When I do admin type things from the GUI, some things (update manager) need my user password and others (backup tool) needs the root password. As a result whenever a password box jumps up, I don't know which one it's asking for. If I understand correctly it's not improving security anyway, so I'd like to revert to how it was out of the box.
I've taken a full backup of my data to a different physical device, and if the worst comes to worst I can nuke and rebuild. After a bit of searching around, the following magic was suggested, sudo passwd -dl root which is supposed to disable the root account.
Is that what I want to do? What's the worst that could happen? Will that leave me able to sudo with my main account password? Are there any investigations it would be prudent to do on my machine, existence of control files for instance, before trying this?
|
sudo by default asks for the calling user's password, but it can be configured to ask for either the password if root or the target user (which is also usually root).
The relevant configuration line would be Defaults rootpw or Defaults runaspw in /etc/sudoers, those would match the behaviour you describe.
Removing them would reset the default behaviour. You should probably use visudo to edit the configuration file.
manual:
rootpw If set, sudo will prompt for the root password instead of the
password of the invoking user when running a command or edit‐
ing a file. This flag is off by default.
runaspw If set, sudo will prompt for the password of the user defined
by the runas_default option (defaults to root) instead of the
password of the invoking user when running a command or edit‐
ing a file. This flag is off by default.
If that was what sudo was configured to do, it means you have a password set for root, and the password can still be used to log in as root or change to root using su (not sudo). To disable/lock the password, you'd need to use e.g. that sudo passwd -dl root. The command is passwd, not password, for the same reasons all the other commands are so short. -d there deletes the old password hash, and -l adds a ! to lock the hash so that it's unusable.
This doesn't actually lock the whole account, it only makes the password unusable. You could still log in as root via SSH keys or such, but you probably have none installed.
| change root password back to user password |
1,669,048,418,000 |
I am trying to parental control myself by restricting web access via OpenDNS. The OpenDNS account password will be handed to someone trustworthy. Now, I want to put some restriction on the /etc/resolv.conf, perhaps using a key or password, but not the root password. Also I do not want to compromise the accessibility by the kernel. Is this possible?
|
No, not the way you're trying to do it. Root has access to every file on the system. You can make it harder to modify the file (note: it has to be publicly readable), but if you have root access, you can't prevent yourself from modifying it.
There is no password protection feature for files. Even if there was one, being root, you could remove it. (You can encrypt a file, but that makes it unreadable.)
One way to make it harder to modify the file is to set the immutable attribute: chattr +i /etc/resolv.conf. Then the only way to modify it will involve running chattr -i /etc/resolv.conf. (Or going to a lower level and modifying the disk content — with a very high risk of erasing your data if you do it wrong.)
If you want to put a difficult-to-bypass filter on your web browsing, do it in a separate router box. Let someone else configure it and don't let them give you the administrator password.
| Password protecting a system file? (e.g. /etc/resolv.conf) |
1,669,048,418,000 |
I'm attempting to copy a public key to a remote server. I'm logged in locally as [localname] and the key resides locally at ~/.ssh/. I'm also ssh'd into [remote.com] as [remotename], and attempting to upload the key thusly:
scp [localname]@localhost:~/.ssh/id_rsa.pub [remotename]@[remote.com]:/home/[remotename]/.ssh/uploaded_key.pub
I see the welcome message for [remote.com], but then I'm asked:
[localuser]@localhost's password:
But [localuser]'s password (the one [localuser] uses to log in to the local machine) isn't accepted:
Permission denied, please try again.
Here's the verbose output:
Executing: /usr/bin/ssh '-v' '-x' '-oClearAllForwardings yes' '-n' '-l' '[localname]' 'localhost' 'scp -v' '~/.ssh/id_rsa.pub' '[remotename]@[remote.com]:/home/[remotename]/.ssh/uploaded_key.pub'
OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/[remotename]/.ssh/identity type -1
debug1: identity file /home/[remotename]/.ssh/id_rsa type -1
debug1: identity file /home/[remotename]/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu7
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu7 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/[remotename]/.ssh/known_hosts:5
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
*****************************************
** This is [remote.com] server **
** Unauthorized access is PROHIBITED **
*****************************************
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/[remotename]/.ssh/identity
debug1: Trying private key: /home/[remotename]/.ssh/id_rsa
debug1: Trying private key: /home/[remotename]/.ssh/id_dsa
debug1: Next authentication method: password
[localname]@localhost's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[localname]@localhost's password:
Can anyone verify that this is the correct usage of scp, or offer troubleshooting tips?
Localhost: Terminal 2.1.2 on Mac OS X 10.6.8 | Remote: Ubuntu 10.04
|
That seems overly complicated. Try using the following from localhost:
scp ~/.ssh/id_rsa.pub [remotename]@[remote.com]:.ssh/uploaded_key.pub
| scp: localhost password not accepted |
1,669,048,418,000 |
In the /etc/passwd file on my system, the "comment" field, field 5, is inconsistent in its contents. I thought that I could extract it to get the full name of the user.
fullname=`awk -F: '$1 == name {print $5}' name=$LOGNAME /etc/passwd`
However this returns with $fullname containing a name with 0, 3, or 4 commas following. Exploring the man page (man 5 passwd) provides no details of this field other than describing it as "user name or comment field."
Perhaps there is additional information that is stored along with the user name?
|
This field is often formatted as a GECOS field, which typically has 4 comma-separated fields for extra information in addition to the user's name, such as phone number, building number, etc.
In all cases I have seen, if the field has a comma, the name is what is before the comma. But I can imagine cases where this is not the case (a name of "Foo Bar, Jr" would break, for instance).
| Where can I find a reference to the format of the comment field (field 5) of the /etc/passwd file? |
1,669,048,418,000 |
I normally ssh into a remote server, for which I previously set an option that allows me not to type my password every time. Now that I forgot it, is there any way to retrieve it?
|
No. User account passwords on Unix systems are saved with one-way encryption and cannot be retrieved. They can only be reset. You will need to login as root or some other privileged account and reset the password for your user.
| retrieve password on remote server |
1,669,048,418,000 |
Checking the two files /etc/passwd and /etc/shadow on a standard Linux distro, it appears all entries are duplicated in both files:
in /etc/passwd, all entries are duplicated (2 lines for each entry, including for root and the user name)
in /etc/shadow, all entries are similarly duplicated.
Any thoughts as to why and how does that happen? And remediation if need be?
Cheers.
|
This is unexpected and non standard. Each username should have exactly one entry in /etc/passwd and no more than one entry in /etc/shadow.
Remediation should be handled with care. For starters I'd get a root shell up and running, and I wouldn't log out of it until I was sure I could safely log in after my editing. Second, I'd take a copy of both files (and note permissions and ownerships) in case I had to revert.
Then I'd use something like sort -u /etc/passwd and check visually to see if that resolved the duplication. Same for /etc/shadow.
If not, I'd take an account for which I knew the login details, and I'd discard the second of each duplicate. For both files. Trying to login, if it worked I'd apply the same logic to all entries in both files.
Otherwise I'd need to see some concrete example entries.
Basically, you will need to fix the problem by visual inspection.
| Entries in /etc/passwd are all duplicated (and entries in /etc/shadow are also all duplicated) |
1,669,048,418,000 |
A few weeks ago, I decided to clean up my keyboard and ended up messing up a few keys as I was snapping them back onto the board. As a result, some characters have become annoyingly difficult to enter... And obviously I use a few of said characters in my password.
I am planning to replace my keyboard of course, but in the meantime, having to go through 4-5 login attempts a day on my ttys is starting to get on my nerves (I don't use a desktop manager).
I've managed to alleviate the issue a bit by setting pwfeedback in my sudo config. This allows me to "see" whenever my keyboard skips a character. However I couldn't find a similar option for the agetty and login combo.
Is there a way to activate password feedback for the tty login prompts?
|
Alright, to the source code we go!
util-linux's login program is in charge by the time my login prompt appears. Let's start there, more specifically in the login-utils/login.c file.
Now, login appears to be in charge of the login prompt, since it generates it in loginpam_get_prompt and registers it with PAM in init_loginpam. The loginpam_auth function then takes over, and control goes to PAM's pam_authenticate function. This means that login merely defines a prompt for the username and that's it.
To PAM then: what we're interested in clearly happens in pam_authenticate :
The pam_authenticate function is used to authenticate the user. The user is required to provide an authentication token depending upon the authentication service, usually this is a password, but could also be a finger print.
Now, shadow-based authentication (/etc/passwd, /etc/shadow) is handled by the pam_unix module. My distribution (Arch) provides PAM through the pam package, which means our journey continues over to linux-pam.org and its source code. modules/pam_unix/pam_unix_auth.c seems a good place to start. PAM modules provide their authentication mechanism through a pam_sm_authenticate function, which we find here. The password (or "authentication token", see above) is fetched with a call to PAM's pam_get_authtok function. It is declared in the security/pam_ext.h header file, so that's where we're going next.
extern int PAM_NONNULL((1,3))
pam_get_authtok (pam_handle_t *pamh,
int item,
const char **authtok,
const char *prompt);
Nothing too promising in those arguments but well... Let's see the definition. pam_unix passed NULL for the prompt argument and PAM_AUTHTOK for item, so we end up here. Now that hardcoded PAM_PROMPT_ECHO_OFF given to pam_prompt just doesn't look good for me...
retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0], "%s", PROMPT);
By the way, the password PROMPT is also hardcoded (here), so there goes my dream of a more exotic password prompt... Anyway, let's go over to the pam_prompt function. The actual prompt happens here, where PAM calls a conversation function fetched a few lines above. A quick look at the pam_get_item and pam_set_item functions introduces us to the pam_conv structure defined here.
Now, finding information on the default PAM conversation function was a lot trickier than it should be (I think). Everywhere I looked, the structure remained uninitialised and pam_unix does not appear to define its own. However I managed to find the generic misc_conv function, which passes PAM_PROMPT_ECHO_OFF over to read_string and... here's where PAM deactivates input feedback.
Conclusion: the absence of password feedback is hardcoded. Too bad. A little digging got me to this GitHub issue and this Arch BBS thread. Apparently, the feature was available back when PAM wasn't a standard for authentication. I guess it makes sense not to have implemented it again - security and all - but you know, an option would have been nice.
Anyway, I've just ordered my new keyboard.
| Can I activate password feedback on a tty? |
1,669,048,418,000 |
Is there a way to have getmail get the password from a gpg encrypted file instead of leaving it in plain text?
|
Yes you can.
Add your key to gpg-agent or gnome-keyring, and configure either gpg -d or pass to write to stdout without prompting for key unlock. Mind to only include the password in the file. In ~/.getmail/getmailrc:
password_command = ("/usr/bin/pass","email/gmail.pw")
I installed getmail 5.5 from the official website instead of using the ubuntu-xenial repo (4.48) to get the password_command working.
| Can I store my getmail password in a gpg file? |
1,464,713,832,000 |
In my search for a simplistic password manager, I found 'pass' and made it my choice. One unexpected difficulty, that I encountered, is that web searches about its features are difficult to phrase in a way that produce desired results - simply due to its name. I consequently wasn't able to find an answer to the following two questions:
Can I unlock pass for my entire session? I wrote a couple of scripts that ask 'pass' for a particular password, instead of saving this password in a plain text (which I am not willing to do). As an example of this, I use emacs and mu4e in connection with offlineimap in order to obtain my emails and it can be rather annoying to retype my password every time I want to update my inbox. It would be nice if there was a way to unlock my password manager for a set amount of time or an entire session.
Provided that my first question has a positive answer: How can I use pass to provide the passphrases to my ssh keys? I use ssh on a daily basis on a few different machines and defined alias for them. Obviously I could make the password, in plain text, part of this alias, but this isn't acceptable for me. I could also write a small script that first asks pass for the passphrase and then establishes my ssh connection. I wonder if there is a 'simpler' solution.
|
pass uses gpg to encrypt your passwords. This means you can use gpg-agent to cache your passphrase, thereby allowing the gpg tools and therefore pass to decrypt its files without asking for your passphrase again. If you're using GnuPG >= 2.1.0, gpg-agent will be started automatically. If not, there are (unfortunately) numerous ways to have gpg-agent start along with your login or X session.
The Arch Wiki contains a lot of information about how to configure and use gpg-agent, but the most important one is probably the following entry in ~/.gnupg/gpg-agent.conf:
default-cache-ttl 3600
This allows adjusting the time (in seconds) that gpg-agent will remember your passphrase. The default is 60.
2. You can also use gpg-agent to cache ssh keys. Unfortunately I've never managed to set this up reliably, so I can't give you any hints here.
Also, unrelated to your questions, but auth-password-store integrates pass with Emacs' auth-source mechanism.
| Can I unlock 'pass'? |
1,464,713,832,000 |
On my Macbook, my SSH private key is encrypted, but I never have to re-enter the passphrase even if I reboot the machine.
The system must be unlocking it along with my user account.
Is it possible to set it up the same way for my user account on a CentOS server? There should be some sort of option that would basically encrypt the privatekey with the user account password (or at least encrypt the passphrase with the user password). I do not want the private key in plaintext on the hard disk, and would prefer not to have to enter many passwords.
If the answer is no, then I probably will need to enter it once each time the server is booted. That is less good, but since that should be a rare occurrence, that would be tolerable.
|
You need a keyring or keychain to maintain the ssh-agent auth socket location for you.
On CentOS you can install keychain, see http://www.cyberciti.biz/faq/ssh-passwordless-login-with-keychain-for-scripts/ for a detail guide on how to setup keychain on CentOS.
| ssh-agent: How to set it up so my CentOS server will only ask for passphrase once? |
1,464,713,832,000 |
I'm implementing a security policy that will force the users to introduce stricter passwords when they change their own:
The /etc/pam.d/passwd configuration file is:
#%PAM-1.0
auth include common-auth
account include common-account
password include common-password
session include common-session
So, I made changes in this file /etc/pam.d/common-password.
The default common-password file comes with this two lines:
password requisite pam_pwcheck.so nullok cracklib
password required pam_unix2.so use_authtok nullok
I need to add several options to the pam_pwcheck (no problem with that) and another PAM module (pam_cracklib) to make the passwords stronger. Next, it is my final /etc/pam.d/common-password file, included from passwd:
password requisite pam_cracklib.so minclass=3 retry=3
password requisite pam_pwcheck.so nullok cracklib minlen=10 remember=5
password required pam_unix2.so use_authtok nullok
My problem occurs when I have both PAM modules configured: if I introduce a correct password, it works fine. If I introduce a bad password that must be rejected by pam_cracklib (for example, a password with only lower case letters), it works fine (rejects the password without problem).
But when I introduce a password that is valid for cracklib but not for pwcheck (a password with upper case, lower case and numbers of 7 characters length), it rejects the password, but this error is shown:
Bad password: too short
passwd: Authentication token manipulation error
So, pam_pwcheck print its error message (Bad password: too short), but something bad happens with the PAM chain.
Do you know what is wrong in my configuration?
P.S. The "security" requirements are not mine at all, so please, avoid comments on it ;-).
|
I finally get it working only inverting the order of the two first modules:
password requisite pam_pwcheck.so nullok cracklib minlen=10 remember=5
password requisite pam_cracklib.so minclass=3 retry=3
password required pam_unix2.so use_authtok nullok
Now, I'm facing another error, but I will ask it in another question.
| Avoid "Authentication token manipulation error" on password change |
1,464,713,832,000 |
After reboot my centos 7 login is not working.
I can't login, it always appears "login incorect".
I remember that the last significant change I made was in the file "sudoers". I added:
username ALL=NOPASSWD: ALL
|
You can break the CentOS password Using below mention steps.
1.Reboot the system.
2.Interrupt the boot loader countdown by pressing any key.
3.Move the cursor to the entry that needs to be booted.
4.Press e to edit the selected entry.
5.Move the cursor to the kernel command line (the line that starts with
linux16
Append to that line: ðŸ¤
rd.break
(this will break just before control is handed from the initramfs to the actual system).
6.Press Ctrl+x to boot with the changes.
# mount -o remount,rw /sysroot
# chroot /sysroot
# chage -l root
# chage -E -1 root
# passwd root
# touch /.autorelabel
Type exit twice.
The first will exit the chroot jail, and the second will exit the initramfs debug shell
| Login incorrect after reboot |
1,464,713,832,000 |
The shell script that I have to write has to create new users and automatically assign them to groups. This is my code so far:
echo -n "Enter the username: "
read text
useradd $text
I was able to get the shell script to add the new user (I checked the /etc/passwd entry). However, I have tried and I am not able to get a passwd (entered by the user) to the newly created user before. If anyone could help me assign a password to the newly created user it would be of much help.
|
Output from "man 1 passwd":
--stdin
This option is used to indicate that passwd should read the new
password from standard input, which can be a pipe.
So to answer your question, use the following script:
echo -n "Enter the username: "
read username
echo -n "Enter the password: "
read -s password
adduser "$username"
echo "$password" | passwd "$username" --stdin
I used read -s for the password, so it won't be displayed while typing.
Edit: For Debian/Ubuntu users -stdin won't work. Instead of passwd use chpasswd:
echo $username:$password | chpasswd
| How to add users to Linux through a shell script |
1,464,713,832,000 |
The 'pass' password manager uses gpg keys.
http://www.passwordstore.org/
However, gpg itself can be used for symmetric encryption of files.
Does pass only work using public/private keys, or is it possible to use with symmetric encryption?
|
The pass password manager requires a public key for encrypting its files (where the managed passwords are stored) - and it requires a private key to decrypt its files.
It isn't possible to configure pass to use gpg's 'pure' symmetric file encryption (cf. the -c or --symmetric GPG options).
This is due to the design of pass - using GPG's public key cryptography for file encryption/decryption allows for flexibility, e.g. for configuring multiple keys - say - such that a group of users has access to the managed passwords.
Also note that GPG uses a hybrid scheme when encrypting a file for one or many recipients (i.e. using one or many public keys): it randomly generates a session key for the symmetric encryption of the file and then just uses the public key/keys to encrypt the session key.
| 'Pass' password manager - does it require public key? |
1,464,713,832,000 |
I am sure this question has been asked before but I can't find an answer.
I would like to configure Linux so that when I enter specific commands (e.g. apt-get), I wouldn't have to enter password as I have to right now.
How can I do this?
|
You can't configure Linux not to require sudo. Some commands need to be executed as root; if you want to trigger them from an unprivileged account, sudo or some other privilege escalation mechanism is necessary.
You can configure sudo not to require a password for specific commands, by adding a sudoers rule with the NOPASSWD: tag. Note that NOPASSWD rules must come after non-NOPASSWD rules that match the same command.
%admin: ALL = (ALL:ALL) ALL
%admin: ALL = (root) NOPASSWD: apt-get
Note that allowing apt-get is as dangerous as allowing any command, since the caller could pass options that cause apt-get to download packages from sources that they specify, that cause it to invoke hooks that they specify, etc.
If you feel you're seeing too many prompts, you can make sudo prompt you less often. Turn off the tty_tickets option so that you can authenticate once for the whole session instead of once per terminal. By default, the timeout after which you need to enter your password again is 15 minutes.
| How can I configure Linux to not require sudo for specific commands for specific users? |
1,464,713,832,000 |
I'm using zsh on Ubuntu 14.04 over SSH using Putty and I'm setting up the key bindings for my keyboard. Because zsh doesn't seem to make use of my function keys I thought I'd setup scripts to do operations similar to what the pictures on the keys represent. I'm working on the email button and I have it working pretty well but I would like it to be better. This is what I have in ~/.zshrc:
# Ensure we are in emacs mode
bindkey -e
# This requires you to enable the ATOM feed in Gmail. If you don't know what that is then
# go ahead and try this and let it fail. There will then be a message in your inbox you
# can read with instruction on how to enable it. Username below should be replaced with
# your email id (the portion of your email before the @ sign).
_check-gmail() {
echo
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
echo
exit
}
zle -N _check-gmail
# F2 - Display Unread Email
bindkey "^[[12~" _check-gmail
When used like above it works. I'm having two problems.
First and foremost, I would rather have it ask me for a password instead of leaving it in the script like this. This can easily be done by removing :password from the curl command at the command line but when used within this file it causes problems. Specifically, it appears to accept the first key press but the rest drop out to another shell which is not the password input.
Second, the first time I run this in a shell it works perfect. After that it doesn't return to the prompt correctly. I need to press Enter to get another prompt. Is there a way to fix that?
I've put the complete key bindings section of my .zshrc file on GitHub.
|
The problem is that curl expects some normal terminal settings and zle doesn't expect you change the terminal settings. So you can write it instead:
_check-gmail() {
zle -I
(
s=$(stty -g) # safe zle's terminal setting
stty sane # sane settings for curl
curl -u username --silent "https://mail.google.com/mail/feed/atom" |
tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' |
sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
stty $s # restore zle's terminal settings
) < /dev/tty
}
| How can I check GMail messages with prompt for password from a script? |
1,464,713,832,000 |
I'm looking to ssh from my localhost to a remote server, and from there to a remote computer. I currently have it set up so that the remote computer and remote server have passwordless ssh-ing set up between them, but if I ssh from my localhost into the server, and then try to ssh to the computer from there, I get:
Enter passphrase for key '/home/user/.ssh/id_dsa':
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive).
If I try to ssh from a terminal open on the remote server to the remote computer, it works just fine. Does it have something to do with my display not being :0.0, or something else entirely? I've tried xhost +local: but been lost past that.
Thanks
|
If both systems have the public key of your local system use -A.
From ssh(1)
-A Enables forwarding of the authentication agent connection. This
can also be specified on a per-host basis in a configuration file.
Also be aware of this warning:
Agent forwarding should be enabled with caution. Users with the
ability to bypass file permissions on the remote host (for the
agent's UNIX-domain socket) can access the local agent through the
forwarded connection. An attacker cannot obtain key material from
the agent, however they can perform operations on the keys that
enable them to authenticate using the identities loaded into the
agent.
The result is that when you auth against the second host the auth is forwarded all the way back to the host where you physically reside.
Example:
me@host0:~ $ ssh -A host1
Last login: Thu Jun 14 11:31:53 2012 from 2001:db8::b0
me@host1:~ $ ssh -A host2
Last login: Thu Jun 14 11:41:05 2012 from 2001:db8::b1
me@host3:~ $ ssh -A host3
Last login: Tue Jun 12 10:46:50 2012 from 2001:db8::b2
me@host3:~ $
| Two-step remote ssh without password |
1,464,713,832,000 |
I know that on Linux (at least debian) every password are hashed and stored in /etc/shadow.
However thanks to the libpam-cracklib you can add some rules on passwords. For instance in /etc/pam.d/common-password you can set Difok which is a parameter that indicate the number of letter that can be the same between an old and a new password.
But how linux can know when I type in an new password the similarity with my old pasword as it doesn't know my real password (it just have a hash)?
Thanks !
|
When you ask a PAM module to change a password (or participate in changing a password), the module can retrieve both the new password and the old, as given by the user: as Christopher points out, passwd asks for the old password as well as the new (unless you’re running it as root and changing another user’s password). The module can use that information to compare both passwords, without having to somehow reverse the current hash or enumerate variants.
The PAM functions involved include pam_sm_chauthtok and pam_get_item, whose documentation (and the other pages referenced there) should help you understand what’s going on. You can see how it’s done in libpam-cracklib’s source code.
| How Linux can compare old and new password? |
1,464,713,832,000 |
I am trying to change my password as a non root user :
passwd
The data is updated in /etc/shadow, but checking the permission i get:
---------- 1 root root 6076 Jan 27 17:14 /etc/shadow
cat /etc/shadow
cat: /etc/shadow: Permission denied
Clearly there were no permissions on the file for anyone,
even then the passwd command succeeds, and i am indirectly updating data to a non-previliged resource (shadow file)!
So can anyone explain the mechanism that how the updation takes place in background ?
Explanation with reference to the system calls will be very useful.
|
The passwd utility is installed setuid, which means that when it runs, it runs as the user that owns the file, not as the user that called it. In this case, passwd belongs to root, so the setuid bit causes the program to run with root privileges. It is therefore able to make changes to the passwd and shadow files.
If you look at the permissions for the passwd utility, you'll see something like this:
-r-sr-xr-x 2 root wheel 8.2K 19 Jan 17:24 /usr/bin/passwd
This is from my FreeBSD system - what you see will depend on the OS you are using. The s in the owner execute position (4th column) indicates the setuid bit.
For further reference, the syscall is setuid, and is part of the standard C library.
| How passwd command from non-root account succeeds |
1,464,713,832,000 |
Whenever i save *.gpg files (symmetric password) using emacs the gcr-prompter displays dialog and asks me for password twice! It's so annoying, especially that my emacs remembers the password i type, and when i press escape twice on the dialog boxes, emacs saves the file properly. How can i disable the annoying dialogs? Maybe uninstall gcr-prompter completely?
I use Linux Mint 17 x64 with Cinamon desktop.
|
add this to .emacs:
;; Do not use gpg agent when runing in terminal
(defadvice epg--start (around advice-epg-disable-agent activate)
(let ((agent (getenv "GPG_AGENT_INFO")))
(setenv "GPG_AGENT_INFO" nil)
ad-do-it
(setenv "GPG_AGENT_INFO" agent)))
source: https://stackoverflow.com/a/16829842/3024945
| how to disable gcr-prompter dialogs? |
1,464,713,832,000 |
Members of the sudo group in my Debian install can execute anything without entering a password. This is convenient, but seems like a bad idea.
NOTE: My computer is an ordinary desktop, not a server or something like that.
Should I disable this or is it safe?
Bonus points for explaining what could happen (i.e. possible attack vectors).
|
The sudo command is configured by /etc/sudoers.
This should contain a line like:
%sudo ALL=(ALL) ALL
This allows all members of the sudo group to allow arbitrary commands (on any host as any user).
It requires you to enter your own password unless the line includes the NOPASSWD: part.
You need some way to to administrative tasks like installing new software. The two main ways are either explicitly logging in as root with a dedicated root password or using a privileged user which is allowed to use sudo to do so.
Having NOPASSWD: active is sometimes convenient, but might be dangerous for a everyday account as even scripts can use sudo without any feedback to you.
Without NOPASSWD:, sudo will ask for your own password. This requires you to explicitly acknowledge the command and is a good setting for an everyday account. The only weak point is, that the confirmation is cached for some times, which might be exploited from someone else getting access to your terminal just after you did some sudo thing.
The "right" configuration depends a bit on your situation, but I usually set up a host completely without a root password. This way the only way to do root things is logging in as a regular (personalized!) user and doing sudo.
This way you have lots of control. If multiple persons should be allowed root permissions just add those to the sudo group. Afterwards you can see in the log file who issued which root command at which time. You can even specify which user is allowed to execute which command and much more.
| Is it a bad idea to add myself to the sudo group? |
1,464,713,832,000 |
We have an automated sync-routine that uses useradd to create new users on a Ubuntu 10.04 machine. The application launching the routine provided both username and CRYPT-encrypted password. However, since we changed how passwords are handled in order to include LDAP support, passwords now don't have to be CRYPT but can also be MD5 or SHA-1. In fact, SHA-1 is the new default. This however now causes problems.
I have read up on how /etc/shadow is handled and there doesn't seem to be an id for SHA-1, only for SHA-256/SHA-512($5$ and $6$ respectively). The only thing I found was to change the whole thing from CRYPT to SHA-1. We could do that, but we wanted the whole transition to be as non-disruptive as possible.
Is there a way to use both CRYPT and SHA-1 passwords together?
NOTES
- The main application is a CMS on an entirely different server. The linux server in question is a local machine(slave) at the client's location in order to provide local services.
- We are aware that we could switch the entire system out to use LDAP-only, but, as outlined earlier, we don't want to change everything at once.
|
Why not authenticate those users for which you only have an unsalted SHA-1 hash of their password by another means than /etc/shadow.
Using PAM, you can have as many authentication modules as you want and stack them as you want. You can keep pam_unix.so for some users and use pam_ldap.so for the rest.
| Can linux use a mix of SHA-1 and CRYPT passwords? |
1,464,713,832,000 |
I'm trying to setup a Samba server which asks new users to change their password on their first login and makes passwords expire after 90 days.
I was able to setup the 90 days expiry date but the --pwd-must-change-time doesn't work.
The verbose shows as the data was changed but when I run -Lv it still shows the “must change time” for 90 days ahead.
|
I found a solution to my original question.
At first you can set up the 90-day-expiration policy like I did.
sudo pdbedit -P "maximum password age" -C *time-in-seconds*
Then in order to make the user change his password at first login just type
sudo net sam set pwdmustchangenow *user* yes
The problem I'm having now is that Windows does not allow a user to change their password. It only alerts them that they need to change their password. I'm posting a new question about this new error.
| Password expiry in Samba v3.0 |
1,464,713,832,000 |
The password manager integrated within the Mozilla Thunderbird e-mail program is apparently a little outdated, using 70s crypto (3DES) for storing passwords with a master password, even though there have been changes, albeit very slow (Bug 524403, taking 10 years to fix/improve security, Bug 973759, open).
Is there a way to connect an external (local, GNU/Linux, open-source) password manager without resorting to addons?
Ideally this would be a well-known one like KeePassXC.
EDIT:
My main threat model is a running program (something like a web browser with a bug or two) reading and exfiltrating the password storage file - and this being attacked easily due to weak encryption. My system has full disk encryption (FDE) so when switched off this should not be a concern. My web browser actually cannot access that file (there is a container around the browser, using something like firejail or bwrap) but dozens of other programs run unchecked and "uncontainered".
|
Sure, you could do that, specially if you are willing to recompile Thunderbird itself. However, I must ask What is your threat model? What are you trying to protect from by using a different password manager?
To recap: Mozilla Thunderbird stores a number of secrets (such as email server passwords) so that it can do things like fetching your mail (something you probably want). These secrets can be protected with a master password.
Without it, an attacker that got access to the system (while thunderbird is not running) could grab a copy of your downloaded/cached mails or install a trojan, but -assuming you are using a master password, and that it is strong enough- could not retrieve the secrets it uses to access the mail servers.
You raise that the store is using 3DES, which isn't the best available cipher. I agree with you. However, I consider 3DES is still secure enough (as of 2020) for what it is being used here, even if it would be nice to have an higher iteration count (which is a different issue than the usage of 3DES).
As for what you asked, there are several Thunderbird extensions which claim to do what you asked:
GNOME keyring password integration
GNOME Keyring integration
KeeBird. Use KeePass Password Safe to manage your login credentials.
pass-manager Replace integrated password managers storage with zx2c4's pass
You didn't want to use add-ons, though. Another way to do that, which doesn't actually require integration with Thunderbird would be to move the files holding the password store (key4.db, cert9.db…) to an encrypted location (a separate luks partition, an encfs mount…). You could use symlinks to point them there, or -even better- directly encrypt the whole thunderbird profile, thus also protecting the local files.
However, the whole disk should already be encrypted (unless the machine is always located in a secure location, where physical attacks are not a concern) and thus, why bother with mounting a separate encryption layer for thunderbird secrets?
In summary,
If the threat is an attacker stealing a laptop or hard disk, an encrypted disk fully protects from that, and you don't need thunderbird master password.
If the threat is an attacker getting access to the system while it is running (such as leaving the computer unattended) and you have Thunderbird open, a different store won't help. I think that many people tend to open their mail client when they log in, and leave it open (almost) the whole time (something which would be reinforced if closing and opening it requires providing another password). You would need to defend a different way (e.g. locking the station before leaving it, setting a short timeout before launching the screensaver)
This would only matter if the threat is an attacker accessing the running system yet without the mail client open, in which case they could still perform quite a number of malevolent actions, as mentioned above (locking the session would protect against both of them).
So I suspect that the fact that the Thunderbird password store uses 3DES doesn't really decrease your security in a noticeable way.
| How to connect Thunderbird to a strong password manager? |
1,464,713,832,000 |
How can we write a shell script to become root?
That is I donot want to input the password at prompt it should be within the script itself. I was trying to make but failed to do so.Is it possible, if Yes please Explain.
|
You can write a script using expect tool.
In Redhat, expect package comes by default. But in Ubuntu you need to install it separately.
You can check this by using commands:
$ rpm -qa | grep expect for Redhat
$ dpkg -l expect for Ubuntu
The following script will do your work:
#!/usr/bin/expect
spawn su -
expect "Password: "
send "password\r"
interact
| Shell script to become root |
1,464,713,832,000 |
I want to create a script to run the following BASH command:
mysqldump -u [username] -p [db_name] > [path to backup file]
Which results in a backup file. When running this in BASH, it prompts for a password before continuing.
How do I craft this in a BASH script so that the password is automatically entered?
Can this be done securely?
|
The best kind of approach here is to do something like:
mysqldump --defaults-extra-file=/path/to/auth.cnf ...
Where auth.cnf looks like:
[client]
user=the-user
password=the-password
Then make sure the file is only readable by whomever is meant to run that script. The script itself can be world readable.
| How to add a password to a BASH script |
1,464,713,832,000 |
I want to get the password hash of the sys user in Debian (but the password is preferred). I heard that all password hashes are stored in the /etc/shadow file, but there isn't a password hash for the sys user.
How to get it?
P.S. I have root access.
|
On a usual desktop installation, what you see in /etc/shadow is what you get, and the system users generally don't have passwords set. They're not used for interactive logins, so they don't need passwords.
E.g. on the system I looked at, /etc/shadow has this line for sys:
sys:*:19101:0:99999:7:::
That * is where the password hash would be if the user had a password. But * is an invalid password hash, no password will produce it, so there is no password the user could log in with.
Note that if the password hash field was empty, it might allow login without entering a password. With the Linux PAM libraries, this is controlled by the nullok setting to pam_unix.so (man page):
nullok
The default action of this module is to not permit the user access to a service if their official password is blank. The nullok argument overrides this default.
(if it's enabled, and the password is empty, the module doesn't even ask for the password but accepts the login directly.)
If you really wanted, you could set a password for the system in the usual way, but I would suggest reconsidering what you're doing; there's probably a better way. Also note that they may not have a usable shell set either, e.g. on the system I looked, the sys user's shell is set to /usr/sbin/nologin.
| Where is the system's "sys" user's password hash stored in Debian? |
1,464,713,832,000 |
On a linux distro
user mino report this passwd status
passw -S mino
mino P 04/21/2015 0 90 15 -1
P=passwd ok
04/21/2015 = date creation
0 min pass?
90 max pass valid
15 = ?
-1 = ?
Thanks
|
According to the manual: man passwd:
-S, --status
Display account status information. The status information consists of 7 fields. The first field is the
user's login name. The second field indicates if the user account has a locked password (L), has no
password (NP), or has a usable password (P). The third field gives the date of the last password
change. The next four fields are the minimum age, maximum age, warning period, and inactivity period
for the password. These ages are expressed in days.
| A little help passwd status on linux |
1,464,713,832,000 |
Related to Why is the root password on Linux Mint my user password?
It appears that my Mint 17.3 box has a root password set: I see a password hash in /etc/shadow (it starts with $6$...). I'd like to compare this password hash with my (known) user password.
For whatever reason, I don't trust su - (in the linked question) to not use my password, vs. the root password.
Is there a simple way (in bash, e.g.) to compare a known hash with a known password and see if they match?
|
Find the salt used in /etc/shadow, it's the characters between the second and third $, usually there will be eight.
Use mkpasswd -m sha-512 -S <salt>, and enter the password you think it's suposed to be when it asks. It will output the hash with $6$<salt>$ prefixed.
| Verify password hash in bash script? |
1,410,286,180,000 |
Is is possible to run the passwd command with an option to show the newly entered passwords? By default it doesn't show what I type and I don't want this.
[dave@hal9000 ~]$ passwd
Changing password for user dave.
Changing password for dave.
(current) UNIX password:
New password: bowman
Retype new password: bowman
passwd: all authentication tokens updated successfully.
|
If you really want to go this path and there's no passwd parameter, you can use this Expect script:
#!/usr/bin/env expect -f
set old_timeout $timeout
set timeout -1
stty -echo
send_user "Current password: "
expect_user -re "(.*)\n"
set old_password $expect_out(1,string)
stty echo
send_user "\nNew password: "
expect_user -re "(.*)\n"
set new_password $expect_out(1,string)
set timeout $old_timeout
spawn passwd
expect "password:"
send "$old_password\r"
expect "password:"
send "$new_password\r"
expect "password:"
send "$new_password\r"
expect eof
How it works:
[dave@hal9000 ~]$ ./passwd.tcl
Current password:
New password: bowman
spawn passwd
Changing password for user dave.
Changing password for dave.
(current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
This shell script might also work (tested on Fedora 20 with bash-4.2.47-2 and passwd-0.79-2):
#!/bin/sh
stty -echo
echo -n "Current password: "
read old_password
stty echo
echo
echo -n "New password: "
read new_password
passwd << EOF
$old_password
$new_password
$new_password
EOF
How it works:
[dave@hal9000 ~]$ ./passwd.sh
Current password:
New password: bowman
Changing password for user dave.
Changing password for dave.
(current) UNIX password: New password: Retype new password: passwd: all authentication tokens updated successfully.
| show entered new password in unix "passwd" command |
1,410,286,180,000 |
I'm currently using sudo a lot in a bunch of scripts, which is turning into a bit of a hassle, as some scripts does not allow interactive input (e.g., Makefiles).
Instead of disabling sudo passwords altogether I'm thinking it would be nice if gnome-keyring or some similar keyring software could be used to rememeber the password. Is this a good idea? Is it possible? Any better solution?
|
There is a timeout option provided with sudo.
/etc/sudoers:
Defaults:username timestamp_timeout=time_in_minutes
If you want to keep root rights, just launch your script as root. I agree, this is not optimal but this is actually what you are already doing.
Instead, I would rather group all the stuff that can be done without root privilege together and the ones requesting root privilege together and launch them at two separate times... This is what is usually done :
./configure
make
sudo make install
BTW, if your are on a box with Xorg, you could use gksudo instead of sudo. But again, burying "sudo"s in script is not a good practice.
| Is it possible for sudo to read password from gnome-keyring or similar |
1,410,286,180,000 |
I have root access on a machine shared by others. I think the password constraints are absurd, they are overly excessive in how they mandate the use and ordering of non word characters and make passwords slow to type due to the constant need to use special characters breaking up the password (even though I type I'm always minutely slower with special characters, it seems to break my flow). I can create a long & secure password without the constraints. I want to use my root access to circumvent the password rules to create a password I like and can type quickly.
However, I don't want to change the password constraints themselves. Or more accurately I DO want to change them, I think they are idiotic and don't actually add to security as written, but I shouldn't change them since that is being regulated by a higher authority.
Is there a way I can exploit my root access to set a password that violates these constraints without changing the constraints for anyone else on the system?
|
You could try printf "%s\n" 'username:encryptedpassword' | sudo chpasswd -e - that may be able to bypass the password checking enforced by PAM.
The password must be pre-encrypted, e.g. as in the mkpasswd example by muru. For example:
p=$(mkpasswd -m sha-512 'mysupersekretpassword')
printf "%s:%s\n" 'username' "$p" | sudo chpasswd -e
I'm using printf here rather than echo because echo will interpret and change the ouput for some character sequences that may occur in the crypted password, e.g. \t, \n, \nnn (3-digit octal) and others.
Remember to delete the mkpasswd command from your .bash_history. Or use export HISTCONTROL=ignorespace and prefix the p=$(...) command with a space so it never gets stored in the history. If you are not using bash, use whichever method is appropriate for your shell.
| How to set a password that violates password constraints without changing constraints using sudo |
1,410,286,180,000 |
Say someone gains physical access to my computer, and they want to login to my account and see everything I have. Is it possible that they take the hard-drive out of my computer, modify the file /etc/shadow with a new password, and then use it to login?
In other words, does the Linux password change by simply modifying /etc/shadow?
(All this assuming that there's no HD volume-encryption involved)
|
Once they have the hard disk drive they hardly need your password. They simply mount all partitions according to (your) /etc/fstab. The next step is sudo su - "your account id" (if your id is 501, just sudo su - 501).
Short on using encrypted disk with a good password and all, there is little if any you can do to make your data safe.
This "little" include:
Do not use plain text password in scripts (for instance a cron job collecting email (...=pop("[email protected]","avreyclverpassword"), access to remote hosts, etc.)
Do not use password-less gpg and ssh keys. (Re-type them each time or use an agent to store them in memory.)
| Physically override linux credentials |
1,410,286,180,000 |
For some reason, I suddenly do not need to enter the password when issuing sudo some_cmd.
Entered command just runs without ever prompting password, even if I am not logged in as user root. Commands that need root privileges still need to be invoked with sudo though. I am on Ubuntu 10.04.
Any idea what might have caused this?
|
Say sudo -K, then retry your test. If it starts asking again, all that was happening is that you had sudo configured to remember your password for some time.
On top of this, Ubuntu's default sudo configuration makes it remember your credentials across ttys. This affects ssh sessions, as you've discovered, since each new ssh connection looks like a new terminal to the low-level OS code.
This also affects things like the graphical Terminal app. If you authenticate with sudo, then create a new tab with Ctrl-Shift-T, you'll find that you don't need to give a password to sudo again in that tab, despite the fact that it also creates a new tty. You can even close the Terminal app entirely, and as long as you restart it within the normal password timeout, sudo will run without requiring you to re-enter your password. This behavior may be enough to make you decide you want to keep this feature enabled.
Mac OS X works this way these days, too.
Not all *ixes do. Red Hat Enterprise Linux (and derivatives like CentOS) insist on getting the password on each new tty.
You can disable both behaviors by changing the Defaults line in /etc/sudoers to something like this:
Defaults=env_reset,timestamp_timeout=0,tty_tickets
The env_reset bit should be there already, and isn't relevant here
The timestamp_timeout directive tells it to immediately time out each sudo session. It's like saying sudo -K after every normal sudo command.
The tty_tickets directive ensures that it associates credentials with the tty they were used on, not just the user name. This is supposed to be the default already, and is documented as such on Ubuntu, but they must have built their distribution of sudo to disable this option, for the convenience reasons given above.
| sudo command executes without prompting for password |
1,410,286,180,000 |
So I'm maintaining a server which has a verified SSL certificate setup, however there is a password on the private key and so whenever apache is reboot, we get a message asking for the password. This isn't a major issue, but becomes one when you reboot the machine! When this happens, it will hang at apache startup (I can tell by viewing the syslog through AWS) and then the machine doesn't run sshd and so I cannot access the server any more!
Is there a way to setup apache to use this key without asking for the password? I think one option would be to reissue the SSL certificate but this time not using a password, but then is that unsafe?
|
The reason it's asking for the password is to protect your SSL certificate - in case your server gets cracked, the cracker can get access to both your certificate and the key to it. But as long as a password is required in order to use the key, the intruder won't be able to use it.
If you are convinced that your server is secure enough that there's no way an cracker can get at it, you can remove the passphrase from the key - though I really really don't recommend it!
The way to remove the passphrase is to first make a backup copy of the key. Then run the command
openssl rsa -in backupcopy.key -out keyname.key
You will be prompted for the password, and then openssl will write out a key that doesn't require a password. But again, that is really unsafe.
| Apache boot without asking for passwd |
1,410,286,180,000 |
I am building a script to fully automate a VPS setup, and I need to change the root password. I would like to avoid typing it as the script is running through SSH.
Is there a way to redirect an arbitrary value to the input of passwd command?
EDIT
I know for passwd < passwd_file.txt containing the password twice... I would like to know if there is a more elegant way as it seems a little bit clumsy to use a temp file for this purpose.
|
You don't say what version of UNIX you're using, but on Linux the passwd(1) man page shows:
--stdin
This option is used to indicate that passwd should read the new
password from standard input, which can be a pipe.
So all you have to do is run:
echo 'somepassword' | passwd --stdin
Edit to add: more portable is chpasswd which exists on (at least) both Red Hat and Ubuntu:
echo 'someuser:somepassword' | chpasswd
See the man page.
| Change password in headless mode |
1,410,286,180,000 |
I just started using pass of by Jason A. Donenfeld as a password manager.
I entered a password (e.g. email/[email protected]). To retrieve it I type
pass email/[email protected]
I'm being asked the master password. But then if I type again pass email/[email protected], the master password is not being asked and the password for email/[email protected] is output in the terminal.
For security reasons, I want to be asked the master password each time I retrieve a password. How can I do it?
|
pass uses GnuPG to handle encryption.
Recent releases of GnuPG uses a GPG daemon.
This GPG daemon caches your valid authentication for 600 seconds (default-cache-ttl), which may be refreshed to another 600 seconds if you use GnuPG again within that time, up to a maximum of two hours (max-cache-ttl).
You have two options:
Kill the GPG agent process after each use of pass. You do this with
gpgconf --kill gpg-agent
Configure the "cache max time to live" for the GPG agent (the maximum time a valid authentication is remembered, by default two hours).
This number may be changed by changing the GPG daemon's configuration file.
You do this by adding the following line to your ~/.gnupg/gpg-agent.conf file (you may have to create this file):
max-cache-ttl 0
If a GPG agent is currently running, then make sure to terminate it with the gpgconf command as shown above to ensure that the agent reads the updated configuration file when it is started.
See also the gpg-agent manual, specifically the documentation for the --max-cache-ttl option (which corresponds to the max-cache-ttl configuration setting). The manual also mentions the gpgpconf --kill gpg-agent command.
| Re-ask master password in pass each time |
1,410,286,180,000 |
I don't know it's just my experience or not, but every time I type a wrong password in terminal, it takes 2 or 3 seconds to respond. And I think It's a very long time for a computer.
Does anybody know the reason?
|
This is a security feature. Your machine can hash and check the password near instantly. To prevent someone from trying to brute force the password there is an intentional delay added in.
The delay is done in a few common ways. One, as you describe, is to add a couple seconds to any wrong input. Another is to add a longer delay after several wrong attempts (this is common on web interfaces). A third is to use some sort of exponential back off, so the more attempts the longer the delay. Finally, some systems just lock you out after a small but meaningful number of attempts.
| Why when we type wrong password in terminal it has long delay to respond? [duplicate] |
1,410,286,180,000 |
i was trying to make grub password protected with grub2-mkpasswd-pbkdf2 and it works with centos 7 but i can't understand something about it.
every time i use this command it gives me different hash password for one unique string like 1234.
the results are like
grub.pbkdf2.sha512.10000.5A9xxx
grub.pbkdf2.sha512.10000.E18xxx
my question is:
how both of this hashed password work when copy them into 10_unix file and after update grub and how login process compare my plain password with hashed text in 10_unix file?
i mean it seems it's not something like md5() that result is same for one unique string every time we use it.
|
PBKDF2 is a salted password hash, meaning that in addition to the password, the hash function takes as input another string, the salt, which is generated randomly when the password is set or modified. The idea here is that an attacker cannot precompute the hashes corresponding to common passwords, since they also need the salt. Also, if multiple accounts happen to have the same password, this is not evident since the hashes are randomized. The salt is stored as part of the password hash, and to compare a plaintext password to the hashed one, the correct salt to use is read from the hash.
Compared to a "primitive" cryptographic hash function (like MD5 or SHA-256), PBKDF2 is also iterated, meaning that it runs the underlying hash multiple times in a loop (thousands of times, at least). This is only to make the hash slower to compute, increasing the cost of guessing passwords matching the hashes by brute force.
In the case of grub, the format of the hash appears to be
grub.pbkdf2.sha512.[iterations].[salt].[hash]
The password hashes used by the system (/etc/shadow, see the crypt man page) are also iterated and salted, as any proper password hash should be.
PBKDF2 is only CPU-intensive, and it doesn't use significant amounts of memory. This means it's relatively cheap to compute on GPUs. Newer algorithms like bcrypt (1999), scrypt (2009) and Argon2 (2015) also take this into account, and the usual recommendation is to use Argon2
in new implementations.
For a whole lot of more on password hashes, see
How to securely hash passwords? and
In 2018, what is the recommended hash to store passwords: bcrypt, scrypt, Argon2? on security.SE.
| how does pbkdf2 work? |
1,410,286,180,000 |
I am running Ubuntu 10.04 LTS. I want to use my laptop to play music in a party. MY screensaver does not need a password to deactivate. I would like to allow people to use my computer to play the music they like, but I would like to prevent them to have access to certain directories in the same manner or similar that linux prevents people unauthorized to install programs from the synaptic package manager.
I would like this to be at the level of the command line and the file browser. But with the root password to be able to have access.
Is this done by changing the permissions of the directory? If so how, which is the command from the terminal? Will that also prevent people from executing the files in the directory as well? Can I also block their searching of the directory and contents?
|
The simplest way I can think of is simply creating a new user partyuser, and assigning it read permissions to a 'public' music directory. To make the music directory (with it's subdirectories and files) to become readable by others you run:
# chmod -R r+o /path/to/music_dir
That way this user can not list or access files in your own user's home directory by default. The only easy way to do this is by becoming root. If you wish to have the ability to become root as the partyuser for this reason, simply add the user to the /etc/sudoers file and use sudo.
Also remember to add the user to appropriate groups, that will enable use of the audio and/or graphics etc. on the system.
| How to make a folder request root password to view execute? |
1,410,286,180,000 |
I need to encrypt and decrypt a password using bash script. For that, I'm using openssl.
The decryption is needed because I'm moving the password between hosts.
The weird thing is it looks like the encryption has an expiration time.
To encrypt (not on bash script):
echo P@$$word| openssl enc -aes-128-cbc -a -salt -pass pass:pass_key
to decrypt (on bash script):
dec_password=$(echo -n $1 | openssl enc -aes-128-cbc -a -d -salt -pass pass:pass_key)
if I'm doing the encryption and then running the script it works perfectly.
However, if I'm doing the encryption and in the next day running the script for decryption it fails with the error:
error reading input file
Not sure if time is related but that's the only variable that changed.
Any ideas? Thanks
|
The error you have after waiting some time to decrypt the password, and you mentioning it seems the method "has an expiration time" is because the random generated salt varies over time. (e.g. it will be different every day)
When encrypting, the 1st characters of the encrypted password are the salt used when encrypting with a salt; you should use the same salt for decrypting.
Be aware that if trying to encrypt without salt, in MacOS/ older? openssl versions you have to use the -nosaltkeyword; openssl generates and uses a salt by default.
So to encrypt without salt, you need to do:
echo P@$$word| openssl enc -aes-128-cbc -a -nosalt -pass pass:pass_key
However, when storing passwords, it is bad practice decrypting them to compare them with candidate passwords; later on for comparing scripts you do not decrypt them:
what you do to compare passwords is encrypting a password to check with the same salt (if using salt), and compare the encrypted strings to see if they match.
If it is for forwarding passwords between systems and not storing them, using salt is not so essential, however keep in mind it helps keeping it more secure.
However in case you have strong security needs about encryption strenght, OpenSSL is known for having a weak encryption strength and GnuPG is stronger than openSSL for encrypting.
| encrypt/decrypt string with openssl error |
1,410,286,180,000 |
I use the following code as part of a much larger script:
mysql -u root -p << MYSQL
create user '${DOMAIN}'@'localhost' identified by '${DOMAIN}';
create database ${DOMAIN};
GRANT ALL PRIVILEGES ON ${DOMAIN}.* TO ${domain}@localhost;
MYSQL
As you can see it creates an authorized, allprivileged DB user, and a DB instance with the same value (the password will also as the same value).
DB user ====> ${domain}.
DB user password ====> ${domain}.
DB instance ====> ${domain}.
This is problematic because I need the password to be different. Of course, I could change the password manually from `${domain} after the whole script will finish to be executed, but that's not what I want:
What I want is to type/paste the password directly on execution, interactively.
In other words, I want that me being prompted for the DB user's password would be an integral part of running the script.
I've already tried the following code, which failed:
mysql -u root -p << MYSQL
create user '${DOMAIN}'@'localhost' identified by -p;
create database ${DOMAIN};
GRANT ALL PRIVILEGES ON ${DOMAIN}.* TO ${domain}@localhost;
MYSQL
What is the right way to be able to insert a password interactively, by either typing/pasting directly in script execution (instead changing it manually after script execution)?
|
Just have the user store the variable beforehand with read:
echo "Please enter password for user ${domain}: "; read -s psw
mysql -u root -p << MYSQL
create user '${domain}'@'localhost' identified by '${psw}';
create database ${domain};
GRANT ALL PRIVILEGES ON ${domain}.* TO ${domain}@localhost;
MYSQL
Here, the command read reads user input and stores it in the $psw variable.
Note that just after entering the password value, you'll be prompted for the MySQL root password in order to connect to the MySQL database (-p flag = interactive password prompt).
| Making mysql CLI ask me for a password interactively |
1,410,286,180,000 |
A friend gave me an old Dell to fix for her daughter. So I put Lubuntu on it. I had a disk with Lubuntu on it that came with one of my magazines, so I installed it. This machine won't boot from USB and has no DVD drive.
So I installed. It seemed to install automatically without any guidance. After about an hour or so a login box appeared. I can only assume it's installed.
What is the default username and password? I didn't have to set one, yet it's asking me for one. I've looked online and couldn't find anything.
|
I believe these are the defaults:
username: lubuntu
password: blank (no password)
That's literally nothing, for the password.
Linux Format magazine
If you're using the compilation CD/DVD that comes with this magazine the username should be "ubuntu" with again a blank password.
Ubuntu 14.04 compilation disc
References
What is the default user/password?
How to disable autologin in Lubuntu?
| What is Lubuntu default password when it's distributed by magazines? |
1,410,286,180,000 |
A very strange thing happened:
There is a user that has a HASH:
[root@notebook /home/username/Desktop/b/a] cat passwd-machine
foo:x:2229:3001:,,,System,fooo,-,userid for bar;foobar:/home/foo:/bin/bash
[root@notebook /home/username/Desktop/b/a]
[root@notebook /home/username/Desktop/b/a] cat shadow-machine
foo:$1$9TGbA/j3$qxBpCtr2C3VIKcwcvniQi1:16368:1:90:7:::
[root@notebook /home/username/Desktop/b/a]
[root@notebook /home/username/Desktop/b/a] john -show *
foo::16368:1:90:7:::
1 password hash cracked, 0 left
[root@notebook /home/username/Desktop/b/a]
[root@notebook /home/username/Desktop/b/a] cat ~/.john/john.pot
$1$9TGbA/j3$qxBpCtr2C3VIKcwcvniQi1:
[root@notebook /home/username/Desktop/b/a]
[root@notebook /home/username/Desktop/b/a] cat -vte ~/.john/john.pot
$1$9TGbA/j3$qxBpCtr2C3VIKcwcvniQi1:$
[root@notebook /home/username/Desktop/b/a]
BUT!: It looks like... it has no password assigned to the hash!
If I append the "passwd-machine " file content in my Desktops /etc/passwd and append the "shadow-machine" file in my /etc/shadow.. then I can "su - foo" without any password from a normal user.
How could this happen? The given user "foo" has a hash.
But it looks like... it has no password.. how could there be a hash if I can log into that user without password? Can someone explain this please? It's hard to google for this :\
|
That is actually the md5-based hash for the empty password:
$ mkpasswd -m md5 -S 9TGbA/j3
Password:
$1$9TGbA/j3$qxBpCtr2C3VIKcwcvniQi1
$
| Hash in the shadow file, but no password? |
1,410,286,180,000 |
Authentication is required to perform this action.
Whose password should I enter? Mine? Root's? I can never tell.
|
Yours. What you are looking at is a gksudo window. It is the same thing as sudo, a program that allows you to run things with root privileges by entering your password.
| Whose password should I enter? |
1,410,286,180,000 |
I installed a Ubuntu and it only has a user. I can login to the system without login. It doesn't ask me for un/pwd. but when I am in, and I want to run some commands as root (sudo), it ask for password and not allowing me to run it. No password works. How can I find password for this user or root?
|
By default, on Ubuntu, there is no password for the root account. To run a command as root, you must run sudo, which asks for your own password. The Ubuntu installation creates one account with sudo privileges and asks you to enter a password for that account.
If you've forgotten the password, you'll have to change it. First, you need to be able to run a command as root (as a non-privileged user, you'd have to enter the current password to change it). The easiest way to do this if you aren't fluent with the Linux command line is to boot the Ubuntu installation media and select “rescue” rather than “install” at the menu. Alternatively, at the boot menu (you may need to press and hold Shift when your computer is booting, after the BIOS has initialized, to see the boot menu), select the “rescue” option or edit the command line to add init=/bin/bash at the end — see Lost Password in the Ubuntu community documentation for more details (this page may not be very up-to-date).
Once you get a command line as root, run this command to change your password:
passwd joe
(where joe is your user name). Then reboot into your normal system, and don't forget the password this time.
| Finding root password |
1,410,286,180,000 |
I'm trying to write a bash script which, among several other things, will "log in" as a user (preferably with su if possible) without needing to interact with the password prompt, i.e., will automatically input the password. I only need it to perform one command and then the session can end.
This is for an "automatic checker" for an introductory Linux class I'm teaching. The students have an exercise where they create usernames with specific passwords on their Raspberry Pis (running Raspbian), and I want this script to automatically verify the passwords are correct. The students run the "automatic checker" on their Pis and I verify the output, so they have a chance to fix any errors before turning in. Since this is for a classroom exercise with dummy passwords, the security of these passwords is completely irrelevant.
I know there are already a few questions about automatic logins, but none of them work for me. The closest I've come to a solution is getting the su command to say a terminal is required. Using "expect" will not work because it will require installing packages on the students' Pis.
If there are other ways to verify the passwords are correct then I'm open to those. I don't think I can do a hashed password comparison due to the salt.
|
if you have root :
salt=$(awk -F\$ '$1 ~ /student:/ { print $3 }' /etc/shadow)
hashedpasswd=$(awk -F: '$1 == "student" { print $2} ' /etc/shadow)
expected=$(mkpasswd -m sha-512 given-passwd $salt)
if [ "$hashedpasswd" = "expected" ]
then
echo good
else
echo bad
fi
replace student by revellant string of course.
replace given-passwd as well.
see my question for more details : /etc/shadow : how to generate $6$ 's encrypted password?
| Automatically verify passwords for classroom exercise? [duplicate] |
1,410,286,180,000 |
How can I configure CUPS not to ask for root password to resume or add a printer? Or add users so they're "administrators"? When using KDE Plasma, it asks for root password: "please enter a username and a password" and it has root in the username field.
|
In Arch Linux at least, the proper place to fix this issue is in the file:
/etc/cups/cups-files.conf
The above file (instead of /etc/cups/cupsd.conf) will contain the SystemGroup setting. (That's probably why @simplegamer couldn't find it in the file mentioned in the other answer here.)
The standard way to resolve this issue in Arch Linux is to:
First add the "sys" group to SystemGroup in /etc/cups/cups-files.conf . Here is an example:
# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules...
# This cannot contain the Group value for security reasons...
SystemGroup sys wheel
Second, add the user to the "sys" group:
gpasswd -a your_username sys
Log out, if logged in as that user for the group change to take effect. After logging in as that user run groups to check that the user belongs to the "sys" group. Now the user should be able to manage printers without being asked for a password.
This approach allows users without sudo rights to be able to manage printers, which is the right approach in my situation. We do not have a root account enabled and we have users who should not have sudo rights, but these users should be able to manage printers / printing.
Beware of solutions suggesting that you "set a root password" in Ubuntu.
printing - "Adding Printer" dialog asks for root password? - Ask Ubuntu https://askubuntu.com/questions/20318/adding-printer-dialog-asks-for-root-password
This is related:
Bug #653132 ""Add Printer” dialog requests root password if user... : Bugs : system-config-printer package : Ubuntu https://bugs.launchpad.net/ubuntu/+source/system-config-printer/+bug/653132
| CUPS asking for root password to resume printer on KDE |
1,410,286,180,000 |
After doing some googling I could not find why in the /etc/passwd
shows a ! at the beginning of the line.
It looks like this:
!user:x:0:0:user:/home/user:/bin/bash
any ideas? my only guess is that perhaps the user no longer exist.
|
This essentially does nothing more than changing the username to !user, so if you try to login as user you will get:
No passwd entry for user 'user'
as the username has been changed to !user.
Now if you change the /etc/shadow too and set the username as !user, then you can login as the user !user using the same password used for user.
If you want to block a user from logging in using password, you should add a ! to the password field of /etc/shadow or better use passwd -l command.
| What does it mean a ! before the username field in /etc/passwd? |
1,410,286,180,000 |
Looking in /etc/shadow, I can see several users that have the exact same salt and hash value (and thus password).
How could the system end up like this? Does this mean the password was not generated through passwd (thought passwd randomized the salt)? And is this particularly bad?
|
Setting a password with passwd or chpasswd generates a random salt, so users who happen to have the same password would not have identical hashes. In order to have identical hashes this way, you'd have to have a misconfigured system that somehow doesn't save entropy between reboots, and systems that are so completely identical as to repeat the random seed (that can happen with VMs, especially when resuming from snapshots), and for all the passwords to be generated after reading exactly the same number of bytes from /dev/urandom. This is highly unlikely.
Thus, if you see identical hashes, it means that the hashes were copied. The passwords were deliberately made the same, rather than by coincidentally setting the same password multiple times. Either the administrator directly edited the password database and copying the hashes, or they used something like chpasswd -e to supply hashes.
The only bad consequence of repeating a password hash is that it makes it apparent that the accounts have the same password. With distinct salts, as is normally the case, it would be impossible to tell that two accounts have the same password except by guessing the password.
| Same salt/hash value in /etc/shadow |
1,410,286,180,000 |
The situation:
I have an IP : 192.168.1.1 $IP
username : root (or whatever) $USER
and a passwd: foo $PASSWD
Is there a way to give $PASSWD to ssh ? like
PASSWORD_VAR=$PASSWD ssh -l $USER $IP
user can see the password,
user must "land" on usual interactive shell session.
somme package might be installed on desktop linux if need be.
reading ssh(1) give me no clues. such thing exists in window's world (e.g. Kitty), now I would like to do the same in unix (suse or unbuntu if that matter).
I know how to set up public/private key pair, but this is off topic.
|
It is possible if you can install sshpass, so you can run:
sshpass -p 'password' ssh 192.168.1.1
| providing password to ssh [duplicate] |
1,410,286,180,000 |
The abstract question is:
If script x calls program y, do I need a NOPASSWD entry in /etc/sudoers for x, y or both x & y? (And can x then call sudo -v without a password?)
Details:
I'm trying to figure out what should go into the /etc/sudoers file to allow a user on Ubuntu (i.e., user ID 1000 who has sudo privileges) to execute a pre-configured full backup without entering a password.
My backup script is: /usr/local/bin/backup
(See below for script.)
The actual backup program called by my script is /opt/storeBackup/bin/storeBackup.pl
(See http://storebackup.org/)
I tried several approaches with visudo but regardless of what I tried, I was still prompted for the password when running the script.
I expected that adding a final line to /etc/sudoers (using visudo) like the following would work:
myuser ALL=(ALL) NOPASSWORD:/usr/local/bin/backup
That didn't work. Neither did this:
myuser ALL=(ALL) NOPASSWORD:/usr/local/bin/backup, /opt/storeBackup/bin/storeBackup.pl
Is the problem due to my script calling sudo -v near the beginning? Or is something else the problem?
To execute the following script, I expect the user to open a terminal and type backup. I want it to be that simple and I don't want them to be prompted for a password at all.
#!/bin/bash
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
#do a bunch of stuff that could take a while...
#finally, do backup without asking for password:
sudo /opt/storeBackup/bin/storeBackup.pl -f backup.conf
Thanks
|
I was successful in using the following examples as you've described. Sample scripts:
top.bash
$ cat /tmp/top.bash
#!/bin/bash
echo "running $0"
sudo -v
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash
echo "running $0"
whoami
Now with the following modification to sudo:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
sam ALL=(ALL) NOPASSWD:/tmp/top.bash
Now as user sam:
$ sudo /tmp/top.bash
running /tmp/top.bash
root
running /tmp/bott.bash
root
What about running top.bash without sudo?
If I alter the /etc/sudoers file like so:
sam ALL=(ALL) NOPASSWD:/tmp/top.bash,/tmp/bott.bash
And then just run /tmp/top.bash as user saml:
$ /tmp/top.bash
running /tmp/top.bash
sam
running /tmp/bott.bash
root
I get the above. Which is what I would expect.
| proper configuration of visudo NOPASSWD for bash backup script |
1,410,286,180,000 |
I have an apache web server running on Debian Linux and I secure a certain directory with htaccess. I have no history or knowledge how the .htpasswd file was created. Apache documentations says that crypt() encryption was used to encrypt passwords until version 2.2.17 and MD5 encryption is used since 2.2.18. How may I distinguish which encryption my .htpasswd file uses?
|
I have no history or knowledge how the .htpasswd file was created.
You're probably looking for the htpasswd command. Read the man page for more details:
man htpasswd
How may I distinguish which encryption my .htpasswd file uses?
Why do you need to know that? I don't think it's important to know that if you just want to edit the file.
I'm asking because I had the impression that both of them are vulnerable.
The htpasswd command on my machine can use four different password formats:
# MD5 (default)
martin@martin ~ % htpasswd -m -b -n user pass
user:$apr1$uFKIg3No$ItOJ5p6EEbALwPDYcPDd0.
# crypt
martin@martin ~ % htpasswd -d -b -n user pass
user:qMYdeiUkbhR/o
# SHA
martin@martin ~ % htpasswd -s -b -n user pass
user:{SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ=
# Plain
martin@martin ~ % htpasswd -p -b -n user pass
user:pass
That should help you figure out which format you're using.
I am wondering though what you're concerned about... whether the hashes are vulnerable is only of concern if an attacker is able to gain access to the .htpasswd file, which should be very unlikely in a sane configuration. The .htpasswd file should be stored outside of the served directory, for example somewhere in /etc, where the web server can access it, but will not serve it.
What should concern you much more is the fact that HTTP Basic Auth transmits passwords in cleartext, which is definitely unsafe if you're not using HTTPS. So if you're concerned about security, consider switching to HTTP Digest Auth.
| How may I distinguish encryption algorithm of htpasswd? |
1,410,286,180,000 |
I have a system (VM, actually) with Linux Mint 15 on it. The disk is encrypted, but I remember that password -- just not the password for my account. I've tried changing the command in GRUB from ro to rw init=/bin/bash, per guides online, but that doesn't seem to play nicely with the disk encryption. Is there a way to decrypt the disk, then drop straight to a root prompt (in order to use passwd)?
|
This is actually way easier than you might think. Here's how you do it:
Boot into a Live CD.
Decrypt and mount your partition on your hard disk. If you have a couple of partitions that all get mounted at boot, you will need to mount all of those, and in the correct order. Note that while you can get away with it this time, usually this includes bind-mounting /proc and /dev into the hard drive mountpoint.
I won't go into how to do this, since I forget, but you should be able to find how to online (just search for "mount an encrypted partition linux" or something), or ask a new question here.
If you haven't already opened a terminal, open one, and type chroot /path/to/your/encrypted/drive bash, where /path/to/your/encrypted/drive is where you mounted the hard drive partition.
chroot stands for "change root". Root here is referring to the root of your directory tree, not the root account. Basically any program that you run from now on will see the hard drive, not the CD, as the root of the filesystem. bash at the end tells chroot what program to run from the new root - so you're running bash from your hard drive, not from the CD. bash will think it's executing from something like /usr/bin/bash, but in reality it'll be executing from /path/to/your/encrypted/drive/usr/bin/bash.
If my garbled explanation was unreadable, here's the Wikipedia article and the manpage.
Run passwd.
Type exit to get out of the chroot and reboot out of the CD and into your hard drive.
Profit.
| Resetting password in Linux Mint when disk is encrypted |
1,410,286,180,000 |
I'm looking for a command-line Linux password-manager. It appears that pwsafe is the program most commonly used. However, its latest update was in 2005. Is it a good idea to use this? Has it been so stable that no updates are necessary, or am I risking using outdated software for an important task like password management?
|
IMO it would be better to use a plain text file with a structured format and then GPG or OpenSSL encrypt it. Or even just plain vim encryption.
The advantage of OpenSSL/GPG over vim is that you can decrypt it on the fly and grep the output.
Here's a nice write up for using vim as a password safe.
| Is it a good idea to use pwsafe - a password manager not updated since 2005? |
1,410,286,180,000 |
I have a computer running OpenSUSE 12.1, 64-bit, default install.
How it works currently:
I turn on the computer
It goes through the boot process
At some point during boot, I am asked for password to decrypt an encrypted partition
The problem is there is a timeout on this prompt, so I have to sit next to computer and pay attention to what is going on.
How can I disable that timer, so I could for example turn the computer on and go away, and then return after 1 hour and still see this prompt?
|
Have a look at this Opensuse forum thread. It reveals that it's an issue with systemd's default unit timeout and not respecting the timeout setting in crypttab.
It also provides a workaround -- letting the initrd take care of it, with an /etc/crypttab entry like this (i.e. adding the initrd)
cr_sdb3 /dev/disk/by-id/ata-SHORTENED-part3 none initrd
followed by rebuilding with mkinitrd.
Additionally, the author of the linked post filed a bug report.
| How to disable timeout of password prompt for partition decryption during boot? |
1,410,286,180,000 |
I thought about whether to post this here or in security SE... but decided to go with Unix SE since this isn't really a question about cryptography stuff but more about Linux users / privileges. Maybe my google-fu is weak today but the only things I have come across so far either
have very general handwavy answers about it being a "bad practice" or "frowned upon" without any concrete examples, or
have replies that assume the user without a password has root access or is otherwise throwing away all possible protections.
To be clear: I'm not advocating this and am actually looking for valid reasons not to do this but I'd like to find concrete reasons why rather than just "it's bad". :-)
So with that out of the way, let me set up the example that actually got me thinking about this in the first place:
Let's say that I am considering setting up a home system where I have a strong password on the root account. In addition, I will have a non-root account named fred that is NOT in the admin group wheel (or sudoers on Debian / Ubuntu). On this system, I will also have /home on a separate, LUKS-encrypted partition that gets unlocked during the boot process. In other words, a password does still get entered between GRUB and the login manager - but the login manager is set to auto-login. Beyond this, let's say I also setup (from root): password -f -u fred to force unlock the password for fred (effectively making fred have an empty password).
What sorts of security issues could I expect to run into in this situation? It feel like there ought to be some good reason why you don't want to do this. But the only thing that comes to mind so far is:
LUKS partitions don't get closed when the screensaver lock triggers (at least, not on Cinnamon and assuming one is set to trigger). So if someone broke into my house and fred was already logged in, they could just sit down and turn on the monitor then proceed to look through anything fred has access to - as long as they didn't unplug/reboot/carry off the PC first (and thus re-lock LUKS). And I suspect that if I tried hard enough, I could maybe find a way to call a script when screensaver is triggered and then lock LUKS from said script, thereby closing this hole (or maybe kde/xfce/gnome/etc already have some way to take care of this?).
Even if fred had a nice strong password, he couldn't install software / mess with system settings without being an admin. And, I don't know for sure, but I think browser / Wine access to files would not be changed either way. Is there anything more at risk here than if fred did have a password?
Edit: I don't think it matters but the distribution is Fedora (with SELinux on), but if you feel more comfortable answering with regards to another distribution (or without SELinux) that's fine.
Edit #2: Regarding ssh / samba. I generally setup something like a /media/sdb1/shared folder for rather than using samba's $HOME shares or whatever they're called. I find this fairly easy to setup in a small user setting like at home (I obviously would not do this in a work environment or a setting where not all users trust each other). But I do always use separate, password-protected samba user accounts (not the same users that get logged in with) and I follow several guides on hardening my smb.conf setup. If you see flaws in this setup, I will consider them valid for attacking the hypothetical scenario/setup with a blank password on the login account fred (remember the samba account password is not blank though).
For ssh, I want to confirm that the default is that blank passwords are rejected on all accounts (not just on root). If not, then I will consider FelixJN's answer to be valid. Otherwise, I would - similar to samba - probably use the same setup I normally do which is a hardened version of the default config. I don't recall changing many settings for this so I will try to see if I can find exactly which settings I usually modify and include them here. Off my head, I know I change the port number not that this matters much.
In confirming the ssh rejection, I was surprised to see that on LM19 passwd does not appear to support the -f (force) flag so oddly I was only able to create a blank password non-root user on fedora. When I tried to ssh from the LM19 box to fedora, it was refused:
$ ssh -p 2468 fred@fedora-testbox
fred@fedora-testbox's password:
Permission denied, please try again.
fred@fedora-testbox's password:
Permission denied, please try again.
Aside from port, it looks like I also increased the minimum acceptable ciphers/MACs/KexAlgorithms, reduced LoginGraceTime/MaxAuthTries/MaxSessions, set PermitRootLogin no / UsePAM yes / ChallengeResponseAuthentication no. For PermitEmptyPasswords: no did appear to be the default but I had made my explicit.
|
The biggest practical reason I can think of is that some network software may allow someone to remotely log into your machine without a password. The risk isn't so much the software you know, its the software you didn't think about. Perhaps the software that came packaged with your distribution.
With passwordless users, it's your job to check every network connected service on your machine to see if it will allow remote login without a password.
A general security principle is that you want things to "fail" by locking everyone out instead of letting anybody in. If you have passwordless users then mistakes and simple oversights are more prone to unlock some backdoor somewhere.
One such example might be email servers. If you have a machine with a public IPv4 address then, guaranteed, there will be weekly or even daily attempts to login to SMTP. Hackers just cycle through every single IPv4 address looking for a vulnerable machine (there's only 4 billion addresses).
Likewise SSH. OpenSSH is configured to reject login attempts without a password (without authentication), so that's most likely safe. But I see a few attempts every day from hackers trying to find a username with a blank password. They just cycle through thousands of common usernames in the hope of getting lucky.
| Why would having a user without a password be a bad idea (in this scenario)? |
1,410,286,180,000 |
According to the official Red Had documentation on pam for the account interface:
account — This module interface verifies that access is allowed. For example, it checks if a user account has expired or if a user is allowed to log in at a particular time of day.
However, similar information (on account validity) is incorporated in /etc/shadow file. As the tldp pages mention, some of the last fields include:
The number of days after password expires that account is disabled
The number of days since January 1, 1970 that an account has been
disabled
A reserved field for possible future use
So when does an application (even a PAM-enabled one) reside to when checking account validity?
What happens when rules in /etc/pam.d/application may contradict /etc/shadow?
|
Normally /etc/{group,passwd,shadow} are not used directly, but rather through pam. You can think of pam as kind of a connector that can be configured to use different backends like the /etc/{group,passwd,shadow} things or LDAP to query user information.
To make pam work this way, each backend does have a pam module that can query the backend and retrieve information.
The very basic configuration of pam is to use the pam_unix.so module which retrieves the information from /etc/{group,passwd,shadow} files.
You can also read more about the capabilities of the pam_unix.soin man pam_unix.
| PAM account interface vs /etc/shadow |
1,410,286,180,000 |
This is a way I enter a new passphrase for my encrypted volume:
sudo cryptsetup luksAddKey --key-slot 4 /dev/sda5
Unfortunately, cryptsetup does not ask to confirm the new passphrase. How to make sure that the passphrase I have entered is the one that I actually meant?
I see two workarounds.
Reboot and try the new passphrase.
Add a temporary passphrase to another slot with the help of the new passphrase. Kill the temporary passphrase.
Is there a more elegant way?
|
Just run cryptsetup with argument -y.
From the manpage of cryptsetup:
--verify-passphrase, -y
query for passwords twice. Useful when creating a (regular) mapping for the first time,
or when running luksFormat.
The system would ask twice for an existing passphrase and for a new one:
$ sudo cryptsetup luksAddKey -y --key-slot 4 /dev/sda5
Enter any existing passphrase:
Verify passphrase:
Enter new passphrase for key slot:
Verify passphrase:
Passphrases do not match.
| How to double-check a LUKS passphrase |
1,410,286,180,000 |
Supposing this is how my Oracle VirtualBox machines are being started:
VBoxManage startvm "vmname" --type headless
VBoxManage controlvm "vmname" addencpassword "vmname" "/home/user/vm-name-password"
How do I make the command read the password from standard input on terminal?
Rationale: For security reasons I don't want those passwords stored on the server.
|
After running:
VBoxManage startvm "vmname" --type headless
The following command should ask for the password:
VBoxManage controlvm "vmname" addencpassword "identifier" -
The command uses the identifier visible to the left of the password entry textbox when you start the guest normally with a window. The hyphen at the end causes the request for the password in the command window.
| How do I make this command read the password from standard input on terminal? |
1,410,286,180,000 |
In /etc/pam.d/common-password we have a line such as:
password [success=1 default=ignore] pam_unix.so sha512 rounds=200000
Meaning, whenever anyone sets their password, hash it with 200,000
rounds of SHA-512. This inherently slow hashing protects against
dictionary and brute-force attacks by limiting the speed at which
passwords can be tested.
For some accounts we might want to protect the password better, at the
expense of slower hashing. Say, 500,000 rounds for an admin account, and
800,000 for root. But I have not been able to find any way to specify
such per-user or per-group policies in PAM. Can this be done?
|
You can specify per-user or per-group policies through the pam_succeed_if module. Use the “goto” action (i.e. an integer instead of ok, ignore, etc.) to skip over a password setting for some users.
password [success=1] pam_succeed_if user ne 0
# Setting for root
password [success=1] pam_unix.so sha512 rounds=800000
# Setting for non-root
password [success=ok] pam_unix.so sha512 rounds=200000
(Warning: untested and I'm not fluent in PAM.)
| Set user-specific password hashing rounds in PAM |
1,410,286,180,000 |
I just installed pass on my primary machine and I really like using it. I work on three or four machines and I'd like to synchronize all the passwords I have under ~/.password-store to all my machines. Is this possible? If so, what would be the safest way to do so?
|
The simplest way that comes to one's mind (especially of someone who doesn't know what pass is): use SSH - i.e. scp (sftp or ssh would work as well).
Yet looking at the pass webpage:
It is a very short and simple shell script. It's capable of temporarily putting passwords on your clipboard and tracking password changes using git.
offers a more elegant method. Just use a Git repository as storage backend and you're all set.
| How can I export my passwords to other machines? |
1,410,286,180,000 |
I have mounted an encrypted disk by selecting it in Nemo (1.1.2), then typing a password. I can unmount the disk using Nemo, but now it can be remounted without requiring the password.
Probably there was a "remember" option such as demonstrated in this question.
Regardless of what I selected when I initially mounted, now I want Nemo to forget the password. Is there a way to do this aside from logging out?
This question may also apply to Nautilus (Nemo is a fork).
|
If you really mean "forget the password" it probably already did within microseconds of you entering it.
Persistence of authentication through the login session is maintained in Ubuntu-ish systems by ssh-agent and gnome-keyring-daemon. By their nature of operation (non-invertable hashing) it may be fundamentally impossible to selectively remove one authentication.
As you note, logging out destroys the cached authentication, ssh_agent -k would kill the cache without logging out (but other things would fail to authenticate too).
This looks like you can have single-sign-on ease or fine-grained authentication control, pick one.
| Nemo: Forget encryption password |
1,410,286,180,000 |
I am working on an embedded Linux distro.
I am trying to enforce a password policy through the pam_cracklib.so module
I modified the /etc/pam.d/common-password file, that now looks likethis:
password required pam_cracklib.so minlen=10
password [success=1 default=ignore] pam_unix.so obscure sha512 use_authtok
password requisite pam_deny.so
password required pam_permit.so
So I am trying to enforce a "password of at least 10 characters" policy, but nevertheless, inserting "a" as a password is notified as a bad password but not refused:
passwd
New password: #inserted a
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is a palindrome
Retype new password: #inserted a
passwd: password updated successfully #It should refuse such a weak password
Any tips?
Edit 1: as suggested by @berndbausch, syslog delta (including only the part after changed the password) after adding debug option to pam_cracklib.so is:
May 3 13:00:01 namc8569-xe1 audit[3084]: AVC avc: denied { read write } for pid=3084 comm="passwd" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:passwd_t:s0 tcontext=root:object_r:devpts_t:s0 tclass=chr_file permissive=1
May 3 13:00:01 namc8569-xe1 audit[3084]: SYSCALL arch=14 syscall=11 success=yes exit=0 a0=1011fae0 a1=1011fb18 a2=1011fd18 a3=ff8368c items=0 ppid=3080 pid=3084 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="passwd" exe="/usr/bin/passwd.shadow" subj=root:sysadm_r:passwd_t:s0 key=(null)
May 3 13:00:01 namc8569-xe1 audit: PROCTITLE proctitle="passwd"
May 3 13:00:01 namc8569-xe1 audit[3084]: AVC avc: denied { write } for pid=3084 comm="passwd" name="dev-log" dev="tmpfs" ino=1169 scontext=root:sysadm_r:passwd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=1
May 3 13:00:01 namc8569-xe1 audit[3084]: AVC avc: denied { sendto } for pid=3084 comm="passwd" path="/run/systemd/journal/dev-log" scontext=root:sysadm_r:passwd_t:s0 tcontext=system_u:system_r:init_t:s0-s15:c0.c1023 tclass=unix_dgram_socket permissive=1
May 3 13:00:01 namc8569-xe1 audit[3084]: SYSCALL arch=14 syscall=102 success=yes exit=0 a0=3 a1=bff25db4 a2=6e a3=60 items=0 ppid=3080 pid=3084 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="passwd" exe="/usr/bin/passwd.shadow" subj=root:sysadm_r:passwd_t:s0 key=(null)
May 3 13:00:01 namc8569-xe1 audit: PROCTITLE proctitle="passwd"
May 3 13:00:01 namc8569-xe1 audit[3084]: AVC avc: denied { ioctl } for pid=3084 comm="passwd" path="/dev/pts/0" dev="devpts" ino=3 scontext=root:sysadm_r:passwd_t:s0 tcontext=root:object_r:devpts_t:s0 tclass=chr_file permissive=1
May 3 13:00:01 namc8569-xe1 audit[3084]: SYSCALL arch=14 syscall=54 success=yes exit=0 a0=0 a1=402c7413 a2=bff25828 a3=1001d090 items=0 ppid=3080 pid=3084 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="passwd" exe="/usr/bin/passwd.shadow" subj=root:sysadm_r:passwd_t:s0 key=(null)
May 3 13:00:01 namc8569-xe1 audit: PROCTITLE proctitle="passwd"
May 3 13:00:05 namc8569-xe1 systemd[1]: dev-ttyEHV0.device: Job dev-ttyEHV0.device/start timed out.
May 3 13:00:05 namc8569-xe1 systemd[1]: Timed out waiting for device dev-ttyEHV0.device.
May 3 13:00:05 namc8569-xe1 systemd[1]: Dependency failed for Serial Getty on ttyEHV0.
May 3 13:00:05 namc8569-xe1 systemd[1]: [email protected]: Job [email protected]/start failed with result 'dependency'.
May 3 13:00:05 namc8569-xe1 systemd[1]: dev-ttyEHV0.device: Job dev-ttyEHV0.device/start failed with result 'timeout'.
May 3 13:00:05 namc8569-xe1 systemd[1]: Reached target Login Prompts.
May 3 13:00:05 namc8569-xe1 systemd[1]: Reached target Multi-User System.
May 3 13:00:05 namc8569-xe1 systemd[1]: Starting Update UTMP about System Runlevel Changes...
May 3 13:00:05 namc8569-xe1 audit[1]: USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0-s15:c0.c1023 msg='Unknown class service exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
May 3 13:00:05 namc8569-xe1 audit[1]: USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0-s15:c0.c1023 msg='Unknown class service exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
May 3 13:00:05 namc8569-xe1 audit[3090]: SYSTEM_RUNLEVEL pid=3090 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0-s15:c0.c1023 msg='old-level=N new-level=3 comm="systemd-update-utmp" exe="/lib/systemd/systemd-update-utmp" hostname=? addr=? terminal=? res=success'
May 3 13:00:05 namc8569-xe1 systemd[1]: Started Update UTMP about System Runlevel Changes.
May 3 13:00:05 namc8569-xe1 systemd[1]: Startup finished in 1.703s (kernel) + 1min 31.908s (userspace) = 1min 33.612s.
May 3 13:00:05 namc8569-xe1 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0-s15:c0.c1023 msg='unit=systemd-update-utmp-runlevel comm="systemd" exe="/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
May 3 13:00:05 namc8569-xe1 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0-s15:c0.c1023 msg='unit=systemd-update-utmp-runlevel comm="systemd" exe="/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
|
root (or any user with uid 0) can change its password to whatever is needed, usually (see below).
Try testing with a regular (not uid 0) user
@LL3 added this important info: "Note that it actually is still a matter of policy, because it is pam_cracklib itself that does not return "failure" if the account is root. See the enforce_for_root option of pam_cracklib"
| Bad password is accepted despite password policy |
1,410,286,180,000 |
On my source REDHAT Linux 7 host i fire this command to never prompt for password and passwordless login
ssh -i /app/axmw/ssh_keys/id_rsa -o PasswordAuthentication=no root@<target-host> -vvv
This works for a list of host and I can determine if ssh is working or not non-interactively [with no password prompt].
However, on one particular host 10.0.66.66 it prompts me for the password despite -o PasswordAuthentication flag.
ssh -i /app/axmw/ssh_keys/id_rsa -o PasswordAuthentication=no [email protected] -vvv
Debug of the output of the above ssh command is as below:
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "10.0.66.66" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 10.0.66.66 [10.0.66.66] port 22.
debug1: Connection established.
debug1: identity file /app/axmw/ssh_keys/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /app/axmw/ssh_keys/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version Sun_SSH_2.2
debug1: no match: Sun_SSH_2.2
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 10.0.66.66:22 as 'root'
debug3: hostkeys_foreach: reading file "/home/user1/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/user1/.ssh/known_hosts:315
debug3: load_hostkeys: loaded 1 keys from 10.0.66.66
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour128,arcfour256,arcfour
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour128,arcfour256,arcfour
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha2-256-96,hmac-sha2-512-96,hmac-sha1-96,hmac-md5,hmac-md5-96
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha2-256-96,hmac-sha2-512-96,hmac-sha1-96,hmac-md5,hmac-md5-96
debug2: compression ctos: none,zlib
debug2: compression stoc: none,zlib
debug2: languages ctos: de-DE,en-US,es-ES,fr-FR,it-IT,ja-JP,ko-KR,pt-BR,zh-CN,zh-TW,i-default
debug2: languages stoc: de-DE,en-US,es-ES,fr-FR,it-IT,ja-JP,ko-KR,pt-BR,zh-CN,zh-TW,i-default
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 2034/4095
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:HCTDUmgLFN9OFvbuusL5Z9hZbUXQyZTqS0hGwkbapxA
debug3: hostkeys_foreach: reading file "/home/user1/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/user1/.ssh/known_hosts:315
debug3: load_hostkeys: loaded 1 keys from 10.0.66.66
debug1: Host '10.0.66.66' is known and matches the RSA host key.
debug1: Found key in /home/user1/.ssh/known_hosts:315
debug2: bits set: 1961/4095
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug2: key: /app/axmw/ssh_keys/id_rsa (0x55e36c8cde60), explicit
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug3: start over, passed a different list gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:2019)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:2019)
debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /app/axmw/ssh_keys/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred:
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:
Can you please let me know how to enforce no-password prompt for hosts like 10.0.66.66 when PasswordAuthentication=no option not helping?
|
debug1: Next authentication method: keyboard-interactive
You're being prompted for "keyboard-interactive" authentication, which is technically separate from "password" authentication. Keyboard-interactive is like password, but the server provides the prompt message. It's often used with things like RSA tokens and yubikeys.
You can disable keyboard-interactive by setting KbdInteractiveAuthentication to "no":
KbdInteractiveAuthentication
Specifies whether to use keyboard-interactive authentication. The argument to this keyword must be yes (the default) or no
Alternately, if you're not running this command interactively, you may want to enable batch mode:
BatchMode
If set to yes, user interaction such as password prompts and host key confirmation requests will be disabled. This option is useful in scripts and other batch jobs where no user is present to interact with ssh(1). The argument must be yes or no (the default).
| PasswordAuthentication=no flag does not work on one strange host |
1,410,286,180,000 |
I'm using NixOS. Here's my SSHd config:
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
services.openssh.challengeResponseAuthentication = false;
services.openssh.permitRootLogin = "no";
services.openssh.extraConfig = ''
Match User dropbox
PasswordAuthentication yes
'';
As you can see, I'm disallowing SSH login with passwords, but as an exception, allowing it for the user dropbox. This Nix syntax results into following sshd_config:
UsePAM yes
AddressFamily any
Port 22
X11Forwarding no
Subsystem sftp /nix/store/6fkb47ri4xndlpszjrbw8ggd3vmb6in7-openssh-8.1p1/libexec/sftp-server
PermitRootLogin no
GatewayPorts no
PasswordAuthentication no
ChallengeResponseAuthentication no
PrintMotd no # handled by pam_motd
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 /etc/ssh/authorized_keys.d/%u
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]
LogLevel VERBOSE
UseDNS no
Match User dropbox
PasswordAuthentication yes
On the surface, this seems to work. It doesn't allow password login for other users, but allows for dropbox. This is with ssh -v dropbox@poi:
debug1: Next authentication method: password
dropbox@poi's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
However, it doesn't accept dropbox's password. It's the exact same (simple, three letter toy password) password that allows me to log in, so the password isn't wrong. I've even copy-pasted it to avoid the caps-lock trap. The same password that allows login doesn't allow SSH login.
HOWEVER, if I set passwordAuthentication allowed for ALL users, then dropbox magically is able to log in with it's password. I've verified that the Match part is always in the end of sshd_config, so this is not about ordering issues.
I've never heard this kind of behaviour. Is there any tricks that would allow me to debug this?
|
If you look at the nix source here you can see they are using passwordAuthentication to set a PAM rule. Effectively:
security.pam.services.sshd.unixAuth = <passwordAuthentication>;
There is no way I can come up with to disable PAM in the sshd config [note 2], the nix module hard-codes in "UsePAM yes" to the top of the file. What we can do, instead, is override that setting so that PAM will accept your password.
services.openssh.enable = true;
services.openssh.permitRootLogin = "no";
services.openssh.passwordAuthentication= false;
services.openssh.challengeResponseAuthentication = false;
services.openssh.extraConfig = "
Match User bootstrap
PasswordAuthentication yes
Match All
";
security.pam.services.sshd.unixAuth = pkgs.lib.mkForce true;
Explanation:
PAM is a service available on most Linux systems that handles user authentication, among other things. It can be configured to authenticate in various ways. From the NixOS options reference:
security.pam.services.<name?>.unixAuth
Description: Whether users can log in with passwords defined in /etc/shadow.
Default value: true
The challengeResponseAuthentication line is needed to really prevent password login, since challengeResponseAuthentication and passwordAuthentication refer to two different modes of "password" based login, and they are enabled/disabled independently.
Note: if you forget to use mkForce (or something similar),
nix will yell at you:
error: The option `security.pam.services.sshd.unixAuth' has conflicting definitions, in `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/ssh/sshd.nix' and `/etc/nixos/configuration.nix'.
Note 2: Some (maybe all, IDK) openssh options cannot be changed after they have been set in the config file. Subsequent definitions of the same value are ignored. Therefore, entering "UsePAM no" inside your extraConfig has no effect, since "UsePAM" is already set to "yes" at the top of the sshd_config.
Note 3: NixOS v20.03.1619 (Markhor), OpenSSH_8.2p1
If anyone has more specific info on specifically how PAM or sshd config, or NixOS work, mention it in the comments and I'll add it to the answer.
| Weird behaviour in per-user SSH password authentication |
1,410,286,180,000 |
/etc/shadow contains the username, but not the uid. Is there a specific reason, why a char * field was chosen over an int?
For direct username->password check this might be quicker, but for relations to /etc/passwd a string-comparison on each user seems a little expensive.
I'd like to know the rationale behind this decision.
|
There could be multiple users with the same uid (but different name, home directory, shell, etc) in /etc/passwd. And that was current practice -- IIRC even today, there's a toor "alternate root" account on BSD.
If the /etc/shadow passwords were indexed by uid instead of user name, then which /etc/passwd entry would each of them correspond to?
| Why does /etc/shadow uses user name instead of uid? |
1,410,286,180,000 |
Having read this: https://stackoverflow.com/questions/11700690/how-do-i-completely-remove-root-password I was under the impression that a blank root password, as in modifying the /etc/shadow file for the root entry to be something like this:
root::0:0:99999:7:::
Should allow me to su to root without being prompted for a password.
Please note that I'm not looking for a practical or secure way to do this. I'm aware that public key authentication is a viable way to do this in a sane way through authorized_keys and SSH. That's not what this question is concerned with.
The expected behavior is that either not prompting for a password or at least accept a blank password when prompted (enter key, nothing more) should allow the user to become root.
Actual behavior is that the user does get prompted for a password, and does not accept a blank password (enter key). I also tried su -, su root, su - root. Same behavior. Just to be certain that I actually did change the shadow file I also tried my old password, which also doesn't work, although simply a cat of the shadow file should be enough to confirm that this change was actually carried out. Restoring the original shadow file from my shadow.bak restored original functionality.
This is on a Debian 9 system, su from util-linux 2.32.1.
Is my syntax incorrect? Should it be root::0:0:99999:7::: or is this ability to use a blank password no longer possible? Since when was it removed?
|
Since su is usually configured via pam_unix, it's oftentimes configured with the nullok_secure directive on Debian systems:
$ grep -m1 pam_unix /etc/pam.d/system-auth
auth sufficient pam_unix.so nullok_secure
Changing that default to just nullok should enable password-less su usage.
| Blank root password disabled in modern distros? |
1,410,286,180,000 |
I am using Ubuntu 16.04.3 LTS Server. I have a user with sudo privileges on it. When I attempt to switch from my current user to root, it asks for my password. I enter the correct password and it refuses my password.
username@server:/ sudo su
[sudo] password for username:
Sorry, try again.
[sudo] password for username:
Sorry, try again.
[sudo] password for username:
sudo: 3 incorrect password attempts
Fortunately, I have another terminal window open where I am still logged in as root. So I attempted to reset the password for my user. It says I have updated the user successfully.
root@server:/# passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
So I then attempt to the sudo su command again. It fails with the same messages.
I open a new terminal window for the same user and attempt to sudo su and the same command fails with the same messages.
I also tried unlocking the user sudo usermod --expiredate -1 username. This also did not resolve the issue.
I also tried granting the user "sudo" rights usermod -aG sudo username. And the user still had the issue.
I gave up and just created a new user with sudo rights and started using the new user. The next day I started having the exact same problems with the new user.
The pwck command lists several system accounts and messages about their home directories, but nothing else. The grpck command gives no message at all.
We recently added "pam" authentication about a month ago.
/etc/pam.d/sudo
#%PAM-1.0
session required pam_env.so readenv=1 user_readenv=0
session required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
@include common-session-noninteractive
/etc/pam.d/common-auth
auth required pam_tally2.so deny=5 unlock_time=600
# here are the per-package modules (the "Primary" block)
auth [success=1 default=ignore] pam_unix.so nullok_secure
# here's the fallback if no module succeeds
auth requisite pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth required pam_permit.so
# and here are more per-package modules (the "Additional" block)
auth optional pam_cap.so
# end of pam-auth-update config
/etc/pam.d/common-account
# here are the per-package modules (the "Primary" block)
account [success=1 new_authtok_reqd=done default=ignore] pam_unix.so
# here's the fallback if no module succeeds
account requisite pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
account required pam_permit.so
# and here are more per-package modules (the "Additional" block)
# end of pam-auth-update config
/etc/pam.d/common-session-noninteractive
# here are the per-package modules (the "Primary" block)
session [default=1] pam_permit.so
# here's the fallback if no module succeeds
session requisite pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
session required pam_permit.so
# The pam_umask module will set the umask according to the system default in
# /etc/login.defs and user settings, solving the problem of different
# umask settings with different shells, display managers, remote sessions etc.
# See "man pam_umask".
session optional pam_umask.so
# and here are more per-package modules (the "Additional" block)
session required pam_unix.so
# end of pam-auth-update config
Thanks to @telcoM and @roaima I found that the pam authentication module is the cause of the problem.
root@server:/# pam_tally2
Login Failures Latest failure From
username 53 06/05/18 16:53:42 xxx.xxx.xxx.xxx
While I have found the cause of the problem, I do not understand the behavior. Maybe I have something configured incorrectly in the pam module. Every time I type sudo su (success or not) a failure is added to the pam_tally2. I have no idea why successfully typing the correct password would increment the failure attempts, but it is. Example below.
pam_tally2
Login Failures Latest failure From
username 0 06/05/18 16:53:42 xxx.xxx.xxx.xxx
username@server:/ sudo su
[sudo] password for username:
root@server:/#
pam_tally2
Login Failures Latest failure From
username 1 06/05/18 16:54:03 xxx.xxx.xxx.xxx
Using the sudo -s or sudo -i also result in incrementing the failures in the pam_tally2.
|
You mentioned that there are continuous login attempts from unauthorised external users. If these unwanted remote login attempts referencing root or your username user account it may mean that the pam_tally2 PAM module is locking one or both of them out.
Run the pam_tally2 command to see what is creating the failures. (You may need to run pam_tally2 --user=username --reset to reset the block on username.
Alternatively, this problem report The pam_tally2 counts a good password as a failed login attempt if "ChallengeResponseAuthentication yes" is set in /etc/ssh/sshd_config file may describe your scenario more closely. (I'm still working on finding an alternate source for a solution.)
Incidentally, despite all the best (but wrong) efforts of Canonical, you shouldn't ever need to use sudo su for anything. (It's like saying "Give me root? OK thank you. Now I'm root, I need to become root".) Try sudo -s for a root shell or sudo -i for a root login shell.
| Ubuntu 16 Sudo SU Incorrect Password Attempts |
1,526,032,904,000 |
How to configure bash/zsh to show a small key icon when the prompt asks for a password like Mac terminal?
Is this even possible?
|
Your shell cannot help you because it isn't even active at this point. It's just sitting in the background waiting for the command to terminate. The shell runs the sudo command, after that sudo interacts with the terminal. (Suggested background reading: What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?)
It may be possible for your terminal to do what Mac terminal does. Certainly Mac terminal has this feature. I'm not aware of other terminals emulators with this feature, you may want to make a feature request to the developer of your favorite terminal emulator.
| Show a small key icon when the prompt asks for a password |
1,526,032,904,000 |
I'm writing custom pam rules to restrict/define how users can login to my linux host over the serial console.
If the user guest logs in, I want his password to be verified by pam_unix.so, whereas for any other user, I want my custom authentication program to perform the same task and be the final word on authentication i.e. I don't want any subsequent pam modules to be invoked at all.
Here's my minimal working /etc/pam.d/login file.
# On success skip the next rule
auth [success=1 default=ignore] pam_succeed_if.so user in guest
auth [success=done default=ignore] pam_exec.so expose_authtok /usr/bin/custom-pam.sh
auth [success=1 default=ignore] pam_unix.so nullok
auth requisite pam_deny.so
auth required pam_permit.so
The above config works as expected when I login as guest (and /var/log/journal also confirms this) but fails for other users.
If /usr/bin/custom-pam.sh exits with 0, I expect processing of further modules to stop. From my understanding, success=done should immediately return but that isn't happening.
|
Have you tried the PAM sufficient control? Per pam.conf(5)
sufficient
if such a module succeeds and no prior required module has failed
the PAM framework returns success to the application or to the
superior PAM stack immediately without calling any further modules
in the stack. A failure of a sufficient module is ignored and
processing of the PAM module stack continues unaffected.
This should stop the processing at your custom line:
auth sufficient pam_exec.so expose_authtok /usr/bin/custom-pam.sh
unless it fails, which could be handled by a subsequent nope-denying-you-here line.
| Terminate pam processing at a certain point with pam_exec |
1,526,032,904,000 |
I have two Raspberry Pi (with Raspbian 7 and 8) connected to the same LAN. One has a data connection with an APC UPS. There's a couple of similar scripts in both machines to be ran under power failure situations. In /etc/apcupsd/onbattery and /etc/apcupsd/offbattery (from the UPS attached Pi) I have something similar to:
# [...]
# after the e-mail stuff
# this is for the remote machine
/usr/bin/ssh -f pi@piac-pal_wired "sh -c '/home/pi/bin/my_script.sh > /dev/null 2>&1'"
# this is for the local machine, connected to the UPS
/home/pi/bin/my_script.sh
The local script works, but the one for the remote Pi doesn't (error: "Permission denied (publickey)."
It does work if run it as normal user. Again, it doesn't work if run it with sudo, from the shell.
So I understand the problem is that the root user can't connect via SSH to the other machine using the shared keys method.
Running the sudo ssh command with -vv shows that the offered key is the one in /root/.ssh/id_rsa. The corresponding public key has been already added to the root/.ssh/authorized_keys on the remote machine and its /etc/ssh/sshd_config has been configured including:
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin without-password
If I change the last two lines above in:
PasswordAuthentication yes
PermitRootLogin yes
the root user from the UPS attached Pi can login to the remote Pi, but the command asks for a password, something that can't be accomplished when the apcupsd scripts will run unattended.
Any suggestion is more than welcome. Thanks.
EDIT: adding command output with ssh -vvv as suggested.
I think the relevant part is at the end:
debug3: load_hostkeys: loaded 1 keys
debug1: Host '$HOSTNAME' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:7
debug1: ssh_ecdsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/id_rsa (0x7f8c72a8)
debug2: key: /root/.ssh/id_dsa ((nil))
debug2: key: /root/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug3: no such identity: /root/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
|
The problem was the ssh command was calling the pi user, not the root one, so, the checked authorized_keys was the one in /home/pi/.ssh, not the one in /root/.ssh. All I needed to do was adding the client's root key to the server's /home/pi/.ssh/authorized_keys. That's all.
| SSH passwordless root login gets "Permission denied (publickey)." |
1,526,032,904,000 |
I was debugging kcheckpass under Archlinux. (Because I failed to login with kcheckpass)
Somehow I believe this particular problem is not within kcheckpass.
int
main(int argc, char **argv)
{
#ifdef HAVE_PAM
const char *caller = KSCREENSAVER_PAM_SERVICE;
#endif
const char *method = "classic";
const char *username = 0;
#ifdef ACCEPT_ENV
char *p;
#endif
struct passwd *pw;
int c, nfd, lfd;
uid_t uid;
time_t nexttime;
AuthReturn ret;
struct flock lk;
char fname[64], fcont[64];
// disable ptrace on kcheckpass
#if HAVE_PR_SET_DUMPABLE
prctl(PR_SET_DUMPABLE, 0);
Before the execution of the very first line: prctl(PR_SET_DUMPABLE, 0);
ls /proc/$(pidof kcheckpass)/exe -al
lrwxrwxrwx 1 wuyihao wuyihao 0 Jan 16 16:16 /proc/31661/exe -> /cker/src/build/kcheckpass/kcheckpass
And after executing it:
ls /proc/$(pidof kcheckpass)/exe -al
ls: cannot read symbolic link '/proc/31661/exe': Permission denied
The same with /proc/31661/root and /proc/31661/cwd
I don't see any connection between coredump and read permission of /proc/$PID/exe
UPDATE
Minimal example reproduced this problem:
#include <sys/prctl.h>
#include <stdio.h>
int main(){
prctl(PR_SET_DUMPABLE, 0);
return 0;
}
UPDATE2
kcheckpass and minimal example test are both:
-rwsr-xr-x 1 root root
|
When you remove the dumpable attribute, a bunch of /proc/<pid>/ files and links becomes unreadable by other processes, even owned by the user.
The prctl manpage reads:
Processes that are not dumpable can not be attached via
ptrace(2) PTRACE_ATTACH; see ptrace(2) for further details.
If a process is not dumpable, the ownership of files in the
process's /proc/[pid] directory is affected as described in proc(5).
And the proc manpage reads:
/proc/[pid]
Each /proc/[pid] subdirectory contains the pseudo-files and
directories described below. These files are normally owned
by the effective user and effective group ID of the process.
However, as a security measure, the ownership is made
root:root if the process's "dumpable" attribute is set to a
value other than 1.
And finally, the ptrace manpage reads:
Ptrace access mode checking
Various parts of the kernel-user-space API (not just ptrace()
operations), require so-called "ptrace access mode" checks, whose
outcome determines whether an operation is permitted (or, in a few
cases, causes a "read" operation to return sanitized data).
(...)
The algorithm employed for ptrace access mode checking determines
whether the calling process is allowed to perform the corresponding
action on the target process. (In the case of opening /proc/[pid]
files, the "calling process" is the one opening the file, and the
process with the corresponding PID is the "target process".) The
algorithm is as follows:
(...)
Deny access if the target process "dumpable" attribute has a
value other than 1 (...), and the caller does not have the
CAP_SYS_PTRACE capability in the user namespace of the target process.
| Symbolic link becomes unreadable after prctl(PR_SET_DUMPABLE, 0); |
1,526,032,904,000 |
I am connecting from bastion (server-name) to another server (ecash) through ssh via a key pair.
I have to copy a file called htdocs from ecash to bastion, so I am running:
scp source_user@source_remote_host:/usr/bin/mysql_backup.sh \
target_user@target_remote_host:/var/tmp/
but that's asking me for a password, even though I was connected through a key pair.
And when I enter the password, I get permission denied error (publickey, keyboard-interactive).
Is there issue in the command or file permissions? What can I do?
|
I used this command that worked for me:
rsync -avp ssh --progress /home/ root@ecash-staging:/var/www/localhost/htdocs
| error permission denied (publickey , keyboard-interactive) through ssh (scp) between linux |
1,526,032,904,000 |
I'm started to use unix password manager Pass
Some passwords are not critical to me and I'm using them very often
So it's became very annoying to me to type passphrase to get some password.
Is there a way to type passphrase only once?
|
hymie is right, the question is related to gpg.
The solution is tricky for me, so here's one for OSX:
Install pinentry-mac
brew install pinentry-mac
Create file ~/.gnupg/gpg-agent.conf with lines:
pinentry-program /usr/local/bin/pinentry-mac
default-cache-ttl 86400
max-cache-ttl 86400
When pinentry program requires a passphrase, check box to keep this passphrase
| Pass, how to cache passphrase |
1,526,032,904,000 |
I use pass (standard unix password manager) and it stopped searching linked directories, eg:
> pass find test
Search Terms: test
├── mine -> /mnt/params/.password-store/mine [recursive, not followed]
(...)
> ls -l /home/kossak/.password-store/mine 10:44:32
lrwxrwxrwx 1 kossak kossak 32 2017-01-19 /home/kossak/.password-store/mine -> /mnt/params/.password-store/mine
> ls -ld /mnt/params/.password-store/mine
drwx------ 2 kossak kossak 4096 2021-05-06 /mnt/params/.password-store/mine
Folder mine is not recursive, it is a link to different folder. It was working some time ago, but now it stopped.
Any ideas how to fix it?
I'm using:
pass v1.7.4
Linux Manjaro
|
pass apparently uses tree for the pass find command.
Running the underlying tree command¹ gives the same issue, for me:
$ tree -N -C -l --noreport -P '*test*' --prune --matchdirs --ignore-case /home/user/.password-store
/home/user/.password-store
└── symlink -> /path/to/another/dir [recursive, not followed]
You can also see the "recursive, not followed" error in the tree source code.
An answer about the manifestation of this behaviour in tree says "If the inode number of the directory pointed to by the symlink is found in the hash table (the one that is populated with saveino and findino), it will simply skip it."
I haven't been able to find a solution yet, but my guess is that something strange is going on with the code in tree which saves and looks up inode numbers.
Like you, I also remember that symlinks like this used to work in pass, I don't remember exactly when they stopped working. The last meaningful change to anything tree-related in pass was in 2014, maybe this is a regression in tree, then?
¹To find the tree command, I added set -x above the linked tree -N -C line in password-store.sh
| pass stopped searching linked directories |
1,526,032,904,000 |
I have recently started using mutt to access my email account via IMAP.
My IMAP connection settings are as follows:
set ssl_starttls = yes
set ssl_force_tls = yes
set imap_user = "[email protected]"
set smtp_url = "smtp://[email protected]@smtp.domain.tld:[port]/"
set folder = "imaps://imap.domain.tld:[port]"
set hostname = domain.tld
I have not stored my password so I have to type in my password every time I login
When I start mutt I see the following on the bottom line:
SSL/TLS connection using TLS1.2 (<some string of letters and numbers>)
When I type in my password on being prompted I see the following in the bottom line of my mutt window:
Authenticating (PLAIN)...
Does this mean that mutt is transmitting my password in plaintext?
Thank you for your help.
|
The authentication type PLAIN means there is no specific security protocol for the password itself on the IMAP protocol layer.
But the authentication still happens within the TLS1.2 connection, so unless TLS negotiation has accepted a NULL encryption, the whole connection, including the transmission of the password is protected by the TLS1.2.
To identify the actual strength of the TLS1.2 encryption, you would need to find the actual encryption algorithms and key lengths negotiated on the connection. The <some string of letters and numbers> part in the "SSL/TLS connection using TLS 1.2" message contains this information.
| IMAP authentication by Mutt: Is Mutt transmitting password in plaintext? |
1,526,032,904,000 |
I am currently dual-booting one of my laptops, but I want the Linux distro to be practically hidden completely. So far I have been able to make it so then you have to press Shift for the grub menu to show up, and I have encrypted my Linux root partition (I do not have a home partition). I've heard that you can assign a password to a specific operating system, but I'm a little bit confused about how to do it.
Can I make it so that Windows does not require logging in?
How do I make it so that only my Linux OS is password protected?
(Note: I am using Windows 10 with Zorin OS 15 Core)
Edit: I am not talking about the windows login, I'm meaning, can I have it so then grub doesn't require me to log in to access windows (in the grub menu), but I still need to login into grub to access Zorin. Also, the people I'm trying to prevent from getting into my Zorin root partition aren't particularly smart so I don't really care if they could just use a live USB or something to get into it.
|
Setting up a supervisor user and password will restrict any other user from using menu entries, editing menu entries and from using the grub console. Adding --unrestricted to a menuentry allows any user to use that menu entry without entering username / password and adding --users with a list of user names allows additional users to access a menuentry.
For a minimal setup you need to add a superuser with password and add --unrestricted to the menuentry in /etc/grub.d/30_os_prober that generates your Windows menu entries.
Edit /etc/grub.d/30_os-prober, find the menuentry responsible for the Windows entries and add --unrestricted to this menuentry. In my case I searched for the string Windows and edited the next menuentry line. The edited block now looks like this:
cat << EOF
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --unrestricted $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
EOF
Add your passwords to the end of /etc/grub.d/30_os-prober:
cat << EOF
set superusers="freddy"
password freddy 1234
EOF
Note that it doesn't matter which config file in /etc/grub.d/ we use for our passwords. We could also use 00_header or 10_linux instead.
If you want to encrypt your password, run grub-mkpasswd-pbkdf2, enter your password twice and use the generated string grub.pbkdf2.sha512.10000.<a_very_long_string> as your password. The password entry must then begin with password_pbkdf2 instead of password:
password_pbkdf2 freddy grub.pbkdf2.sha512.10000.68B90AFC[...]86858AF939
Run
sudo update-grub
to update grub and check if your generated Windows entry in /boot/grub/grub.cfg has the --restricted flag. The generated 30_os-prober-block should look similar to this:
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 10 (on /dev/sda1)' --unrestricted --class windows --class os $menuentry_id_option 'osprober-chain-A25E43975E436361' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 A25E43975E436361
else
search --no-floppy --fs-uuid --set=root A25E43975E436361
fi
parttool ${root} hidden-
drivemap -s (hd0) ${root}
chainloader +1
}
set superusers="freddy"
password freddy 1234
### END /etc/grub.d/30_os-prober ###
Reboot and test.
Related links:
Authentication and authorisation in GRUB (GRUB manual)
Grub2/Passwords (Ubuntu documentation with examples)
| How to lock down a specific operating system in grub |
1,526,032,904,000 |
I’m using Ubuntu 14.04. I have this in my /etc/sudoers file
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%deployers ALL=(ALL) ALL
rails ALL = NOPASSWD: /usr/local/rvm/gems/ruby-2.3.0/bin/bundle, /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby, /usr/local/rvm/gems/ruby-2.3.0/bin/rake, /usr/bin/service, /sbin/ restart
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
I thought including the above command (the one with “NOPASSWD”) would prevent getting prompted for a password, but after I reboot my system and login as my “rails” user, note I’m still getting asked for a password when running sudo …
rails@mymachine:~$ sudo rake db:migrate
[sudo] password for rails:
rails@mymachine:~$ which rake
/usr/local/rvm/gems/ruby-2.3.0/bin/rake
What do I need to do so I’m not prompted for a password when running the “rake” command (and other commands I listed)?
|
sudo resets your environment by default, so it won't search your $PATH. So it might be trying to run a system-default version of ruby instead of the one listed. In particular the $PATH seen by sudo is given in your sudoers file:
secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Try using sudo -E to preserve your environment or use the fully-qualified pathname for ruby, or add the paths to secure_path, before the ones given.
| Why am I being prompted for a sudo password when I specified "NOPASSWD" in my /etc/sudoers file? [duplicate] |
1,526,032,904,000 |
On my Amazon Linux (RHEL-derived) system, within /etc/login.defs, I've set the minimum number of days between password changes to 1 day: PASS_MIN_DAYS 1.
I thought I should be doing that with PAM configuration files in /etc/pam.d/. However, I cannot find any documentation for doing so. Is there a way to control when passwords can be changed using PAM, and what is it, please?
|
Setting user Specific password policy:
One option is to modify user password policy - using lchage command.
Below command will set minimum number of days required between pasword changes.
lchage --mindays=<days> <username>
Below command can be used to see current policy
lchage --list <username>
Common Policy for All users:
To set password policy common for all users in system, you need to edit PASS_MIN_DAYS variable in /etc/login.defs file.
root@ubuntu:~# grep PASS_MIN_DAYS /etc/login.defs
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
PASS_MIN_DAYS 1
Above grep listing shows minimum # days required between password changes is 1.
If user tries to reset password before minimum # days set, he/she will get error as listed below.
$ passwd
Changing password for test.
(current) UNIX password:
You must wait longer to change your password
passwd: Authentication token manipulation error
passwd: password unchanged
While creating user, policy defined in /etc/login.defs will be applicable to user being created. Again lchage --list command can be used to see current policy.
| Using PAM, how is minimum number of days between password changes set? |
1,526,032,904,000 |
as my related question doesn't seem to get much love, here another one:
What's the proper way to authenticate a user via username/password prompt in Linux nowadays?
In principle, I suppose I would have to obtain username and password, read salt and hash of the corresponding user from /etc/shadow. I would then calculate the hash of the given password and the stored salt and check if the result matches the hash stored in /etc/shadow.
Normally, I could simply authenticate via PAM (e.g. pam_unix) which does all this already but my application is a custom PAM module and I found no method to call one PAM module from another. If this is possible somehow, I'd gladly go for this solution.
As of now, I found this really dated tutorial http://www.tldp.org/HOWTO/Shadow-Password-HOWTO-8.html from 1996 when, apparently, shadow support was not yet built into libc. It mentions pw_auth and valid as helper functions for authentication. I tried implanting these into my code and linking against libshadow.a of the shadow-tools but I get 'unresolved external reference' errors for pw_auth and valid. The code looks something like this:
if ((pw->pw_passwd && pw->pw_passwd[0] == '@'
&& pw_auth (pw->pw_passwd+1, pw->pw_name, PW_LOGIN, NULL))
|| !valid (passwd, pw)) {
return (UPAP_AUTHNAK);
}
I haven't checked this further but anyway this is not a preferred solution as I'd have to update my code every time shadow-utils are updated.
I'd much rather link to a library (that isn't PAM) that provides authentication against /etc/shadow. Is there such thing and I didn't find it yet? Or some other solution?
|
You fear of an update of shadow-utils is IMO unwarranted. The routines described in that HOWTO are available on my Ubuntu 12.04 and Mint 17 systems without installing anything special.
The structure to read /etc/shadow information in a C program can be found in /usr/include/shadow.h and with man 5 shadow and the functions that you would need to find e.g. a shadow password entry by name as defined in /usr/include/shadow.h is getspnam and that will get you a man page as well (man getspnam) describing that and all related functions.
Based on that you should be able to get the hashed password entry for any given name. The hashed password should have multiple '$' tokens, cut of everything after and including the last '$' from the hashed password and present that as salt to crypt(), the glibc version (according to man 3 crypt) should be able to handle the "extended" salts that indicate SHA512 entries as are more common nowadays.
| What's the correct way to authenticate a user without PAM? |
1,526,032,904,000 |
I've been gently experimenting with roles in Solaris, and wonder a bit about setting a password for it.
I want the role I've created to be used by several users, so setting password to the same as one user (as is done for the root-role) is not an option. Having several users "sharing" (knowing) a single password, I've heard is a bad idea - that is after all the rational behind sudo.
So for now, I've set a blank password (just "Enter"). I did this not by leaving the field in /etc/shadow blank nor by setting it to "NP"... I did it by using passwd to set it to nothing (pressed "Enter" twice) - and the resulting encrypted entry was surprisingly long and garbeled.
So my first question; is it safe to leave a role with blank ("Enter") as password? After all, only logged-in users with that role can assume it...
A few more questions:
Is there some way in the role-specification to specify that a user should authenticate with his own password - rather than the role's - to switch to the role (without changing the role's password to that of the user, as I assume is done with the root-role)? If not, are there other ways (eg. by using sudo - maybe in combination with su? If so, how?) to accomplish this?
How is the root-role bound to the password of the "first user"? Is it some field in the role-specification that makes it happen automatically? What happens behind the scenes to make it happen?
|
Yes, it is safe to remove the password from a role. In fact at my site we do it more or less by default (except for the root role).
As you point out a user that assumes a role has already been authenticated so asking him to authenticate once again is really just too much authentication IMHO.
I believe this also answers your second question. Just remove password from the role!
A few notes on how to remove a password from a role. In the following that role is named roleX.
In Solaris 10
It has always been enough for me simply to do:
passwd -r files -d roleX
In Solaris 11
Something has been changed by Sun/Oracle wrt enforcement of the PASSREQ parameter in /etc/default/login (see man page for login). In order to create a role without a password you need to do as in Solaris 10 on each role account as well as globally setting the PASSREQ parameter to 'NO' in /etc/default/login.
As I see it PASSREQ acts as a last line of defense. You still need to physically remove the password from each account in order for the account not to have a password. I wish Solaris had a setting like PASSREQROLE (my proposal) that would say if it was ok for role accounts not to have a password (rather than for all accounts as is the interpretation of PASSREQ).
| Solaris/OpenIndiana: Password for roles? |
1,526,032,904,000 |
Ok, so here's the deal. When migrating a certain product with terrible documentation to another database type, my Firebird database was deleted. I then proceeded to recover it from the filesystem using a recovery tool. Now, I need to get into it to be able to dump the data and transfer it to MySQL, the new database.
The problem is that the company who makes the software won't give me the username and password to the Firebird database so I can migrate it. The client is justifiably upset as we've had downtime for over a week on this service.
What can I use to get the username and password for the database?
|
The default username/password combination is SYSDBA:masterkey
See also I forgot my Firebird server password, how to get it back?, which advises replacing security.fdb with one from a different database with known credentials.
There's also the general getting help page which links to mailing lists.
| Brute force access to a Firebird database? |
1,526,032,904,000 |
Users get prompted for password, and according to the lsuser -f username output:
expires=0
maxexpired=-1
maxage=13
users shouldn't be prompted for changing password.
Why does he has a change password prompt when logging in?
P.S.:
According to maxage+last password update, his password expired at:
Mon Sep 27 16:26:32 CEST 2010
but the maxexpired=-1 should take care of this, and the user shouldn't be prompted to change the pasaword.
oslevel -s
6100-02-02-0849
|
The maxexpired attribute is the number of weeks after password expiration that a user is allowed to login (and change their password). A setting of -1 disables this restriction. Setting maxexpired=-1 prevents account lockout due to expired passwords; a new password must still be set once the maxage weeks have elapsed since the last password change.
maxage is the attribute that determines the password expiration. Your example has passwords expire 13 weeks after they are set. If you wish to have an account with no password expiration, set maxage=0.
Since you included the expires attribute: expires is the date when the account expires, not its password. Setting this to 0 means the account does not expire. maxage will still determine the password expiration.
| Why does a user get prompted for password under AIX? |
1,526,032,904,000 |
I am on Debian 10 Buster.
When using Nautilus (aka Files), I am always asked for my password when trying to mount another HDD. All normal.
A few days ago, I am not asked for my account password anymore, but for another account password.
So, my main account is in the sudo group. I also have a second account named 'guest'. I am not sure what happened so now every time I try to mount a secondary HDD I am asked for the 'Guest' password instead of my main account password (where I am logged in).
Any help?
Thanks
Edit: If anyone want to know more about this, you can also read the answers on this question: question
|
Ok thinking on this, probably “guest” is sudoer.
Remove guest from sudoer:
-sudo visudo and add comment # on guest line
-remove gest from sudo group using sudo usermod -G guest guest ( look at usermod manual to see proper way to keep all groups but sudo, if other groups are present)
Then try again to mount
If admin password asked and you do not remember root password just do sudo su
then passwd and add a new password
Mount the disk with Admin password
| Why I am asked for the password of a different account when trying to mount a disk? |
1,526,032,904,000 |
When in the graphical environment, seahorse unlocks my ssh key (locked with a passphrase) so I can ssh to another host without entering a passphrase.
But when on the command line, I am still asked for such a passphrase.
Is there a way to have ssh-agent unlock my key on login the way seahorse does? Also, what is the proper way to start ssh-agent on login?
|
sudo apt install keychain
and add
if [ -z "$TMUX" ] ; then
keychain -q ~/.ssh/id_rsa;
fi
. ~/.keychain/$(hostname)-sh 2> /dev/null
to ~/.bashrc
https://linux.die.net/man/1/keychain
| Unlock ssh key on login |
1,526,032,904,000 |
I am using Red Hat Enterprise Linux 7.5 and have instances deployed in AWS. By default accounts are set to go "inactive" after 60 days also, which means an admin will have to unlock the account. I want to make sure this is foolproof to avoid everyone from getting permalocked out, including admins, as these hosts currently do not support LDAP (yet) and may be seldom logged onto. Is there a command/configuration file that by default disables the "Password inactive" setting? Functionality should be the same as chage -I -1 <username> but it's impractical to run that for every account on 3 dozen instances. I just want passwords to expire after 60 days which I have set in /etc/login.defs, but for the system to prompt users to change their password upon login after expiration. Currently it gives an authentication failure until an admin resets the password (chage -d 0 <username>).
Note that password expires designates when he password will no longer work and that password inactive designates when the account will be locked due to expiration (or something to that effect.
# chage -l myuser
Last password change :Sep 19, 2018
Password expires :Nov 18, 2018
Password inactive :Nov 18, 2018
Account expires :never
Minimum number of days between password change :1
Maxinum number of days between password change :60
Number of days of warning before password expires :7
|
The default is set in /etc/default/useradd, e.g.:
INACTIVE=-1
See man useradd for details.
Note that this will change the default for new accounts, but will not affect existing accounts. You will likely want to write a script to update this value for your existing users.
| How to keep password aging but disable password "inactive"? |
1,526,032,904,000 |
How can I generate a CSR for attaching SSL certificate to the site?
In various articles about installing SSL certificates are described different ways of generating private key and CSR. That's like two different versions: (a) openssl req -nodes -newkey rsa: 2048 -keyout myserver.key -out server.csr and (b) openssl genrsa -des3 -out www.mydomain.com.key 2048.
So -
How to generate a CSR and private key?
What is the difference between the teams generate CSR and key (a)
and (b)?
Do I need to set a password when generating the CSR and key?
Reduces whether a site is vulnerable to attack as the password
for the private key?
|
SSL works by matching public and private keys. That is why you first must generate the key, then generate the CSR based on that key. Later, when you are using this certificate, you will find your app or service needs to know where the cert AND where the key is. You need the key to use the cert properly. In some case the key and cert can be concatenated into the same file, or imported to a java keystore.
When you see some flag like '-sha256' on the openssl req, it is telling openssl that you want to put a passphrase on this certificate (this is a very bad idea and a headache, 99% chance you do not want any passphrase. Passphrase just makes it impossible for anyone to view your resource unless they have a passphrase specifically for the certificate. This is never in use, in 7 years I have NEVER seen anyone use an ssl passphrase.
That answers your question of why. Now how do you do it:
openssl genrsa -out mydomain.com.key 2048
Now you just created a key of 2048 bit encryption. You need 2048 minimum now or your cert will fail audit and you have to redo it.
openssl req -new -key ./mydomain.com.key -out mydomain.com.csr
Now you told openssl to create a CSR based on that key you made in part 1. You now have this CSR. You can also use openssl to generate your own unsigned cert, or you can sent to a registrar to provide the cert for you (costs $).
When you get that cert, you will give directive to your app or service telling it where the key is and where the cert is. IF you use an usigned cert, it will still encrypt just as well as signed, but browsers will treat it as untrusted because capitalism (and security).
| How to generate a CSR for attaching SSL certificate to the site? [duplicate] |
1,526,032,904,000 |
/var/log/auth.log logs (among other things) failed login attempts to my Debian Linux.
I was wondering if it is possible to ask it to log the password that was used in the failed attempt.
This is out of curiosity as to the nature of those failed attempts.
Are they using dictionaries? Combinations of words? Length of passwords used?
I feel that knowing the passwords that are being tried might help me to better understand the level of risk posed by those attempts.
|
While it can be done and I'll show how to here, it is strongly recommended not to do this in general case.
Since you basically have passwords sitting around in your log file thus compromising the basic assumption that only you know your password.
You can do it the trick mentioned in this blog post,
You edit a line in one of the files of OpenSSH, then compile it and use it.
Short version, just run following script:
OPENSSH=/opt/openssh2
mkdir -p /opt/openssh2/dist/
cd ${OPENSSH}
wget http://zlib.net/zlib-1.2.11.tar.gz
tar xvfz zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=${OPENSSH}/dist/ && make && make install
cd ${OPENSSH}
wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
tar xvfz openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config --prefix=${OPENSSH}/dist/ && make && make install
cd ${OPENSSH}
wget https://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-6.2p1.tar.gz
tar xvfz openssh-6.2p1.tar.gz
cd openssh-6.2p1
sed -e 's/struct passwd \* pw = authctxt->pw;/logit("Honey: Username: %s Password: %s", authctxt->user, password);\nstruct passwd \* pw = authctxt->pw;/' -i auth-passwd.c
./configure --prefix=${OPENSSH}/dist/ --with-zlib=${OPENSSH}/dist --with-ssl-dir=${OPENSSH}/dist/ && make && make install
For the long and interesting version, read the blog post.
| Logging wrong passwords in /var/log/auth.log |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.