date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,654,423,942,000
I have a requirement (not sure how valid it is). I want to test the password of a normal user (which i just retested). I am logged in as root, and when I switch user from root, it doesn't prompt for a password. I am not sure, if the su command has any option to achieve this. Can someone help me with this?
You could simply use su into that users account from root's account, and then use su again. Weird as it sounds, it does ask for a password when su'ing into your own account, at least on all systems I could get my hands on to try.
How to get a prompt when switching to normal user account when you are already logged in as root
1,654,423,942,000
I'm on fedora 25 gnome, I installed beesu and beesu-nautilus-manager as an alternative for gksu When I try to open an application using beesu it asks me to enter root password, I do that, it says it's wrong, but it isn't. Do I need save my password in seahorse - password and keys application in fedora in order for beesu to work? If so, how to do that?
I've made an ugly script to somewhat emulate gksudo tested on Fedora 31 works with Alt+F2 Usage ~$ wsudo [cmd] (default is gnome-terminal) code Place the following code in /usr/local/bin/wsudo. You also need to install the gtkdialog package #!/bin/bash [ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog MAIN_DIALOG=' <window> <hbox> <entry> <variable>PASSWORD</variable> <visible>password</visible> <action signal="activate">exit:OK</action> </entry> <button ok></button> </hbox> </window> ' export MAIN_DIALOG tmpfile=$(mktemp /tmp/wsudo-XXXXX.$$) $GTKDIALOG -c --program=MAIN_DIALOG >"$tmpfile" . "$tmpfile" rm "$tmpfile" #small script to enable root access to x-windows system xhost +SI:localuser:root if [ -z "$1" ];then echo $PASSWORD | sudo -S gnome-terminal else echo $PASSWORD | sudo -S "$@" fi #disable root access after application terminates xhost -SI:localuser:root #print access status to allow verification that root access was removed xhost
How to use beesu on fedora (the gksu alternative)?
1,654,423,942,000
If you suspected a file might be intercepted, an archive with a password would at least make the contents difficult to recover, but certainly not impossible. It occurred to me that most methods used to crack a passworded archive would quit early if a password worked, so one or more dummy weak passwords could be used to obscure the real content. Of course obscurity shouldn't be the first line of defense, but it can't hurt. Can this be done?
in theory it can, in practice I doubt it. In essence, you would need to craft a message that would have a double hash-collision, one for each password. Suppose you can craft a meaningful msg that would decrypt using password P1 into PlainText1 and using strong P2 into PT2. The problem - crafting PT1 and PT2 such that P1(PT1) == P2(PT2) == E. Edit: @Banaguin raises some good points - if P1 == PT1 and P2 == PT2 you can craft such an equality. The problem is that P1 should be a "weak/trivial" password, while P2 should be a "strong" password. Using P1 == PT1 and P2 == PT2 would not scale for large messages - a 1k text message would become non-trivial to decrypt even for the "weak" password and with lesser probability it will be chosen over the "strong" password. The second problem with this approach is that the "strong" password should be "strong" - if it is the message itself, there is no guarantee that it will be strong, unlike properly crafted passwords.
Can an archive or special file 'contain' different data based on the password used to open it?
1,654,423,942,000
I'm setting up a raspberry pi 3 running the raspbian operating system, that will be connected to wifi constantly with ssh enabled, thus security is a must. I have successfully enabled login via a public-private key pair, and am trying to make this the ONLY way to access the pi via ssh. I've looked at a few threads on this topic, and scoured my sshd_config file for anything that smacks of a password login (PasswordAuthentication, PermitRootLogin, KerberosAuthentication, UsePAM, etc.) to turn them all off, but to no avail. As soon as a login with the public key fails, it immediately prompts for the password. I've restarted sshd and even rebooted the pi several times, but nothing changes. I'm not too desperate since the password is quite strong, but it seems like such a waste to use a public key login if password logins are possible.
in my case i edited /etc/ssh/sshd_config and uncommented the line PasswordAuthentication no, that did it in my case, now if the client send no key or an unauthorized one the server closes the connection. Just make sure the line is not commented #PasswordAuthentication no the # is a comment and gets ignored, and since the default is yes it wont work.
How do I completely disable password ssh logins? [duplicate]
1,654,423,942,000
Is there any secure local service that one should use for storing and retrieving organization wide application passwords? Most of the time we need authentication information in our scripts to run some service. Therefore I need some way to dynamically retrieve a password from my secure store/bucket and pass it as variable in authentication information , instead of hard-coding it in my scripts.
Maybe you can setup oauth? http://oauth.net/ There is also implementation for python(as i saw python in the tags): https://github.com/joestump/python-oauth2 For the rest, If i could I would vote down this question as there is not enough information provided. But ye I assume that you need something like what I've just suggest you
Storing application passwords in central location
1,654,423,942,000
It takes almost two seconds before my linux machine replies the password is incorrect while the correct one gets accepted almost instantaneously.
Actually, that's an intentional delay to prevent someone from being able to brute force a bunch of passwords in a short time.
Why does it take more time to identify an incorrect password than to identify a correct one? [duplicate]
1,654,423,942,000
Suppose I've writen a setuid root executable and I want it to verify that the user is not a script by asking the user to provide his/her password (granted, users might save their password and use that in a script, but that doesn't concern me). What would be a good way to do this? The more portable the better.
Most modern Unix systems use PAM to handle authentication. The pam_unix module is the one that does password authentication against /etc/password and /etc/shadow. However, you shouldn't reinvent the wheel. Asking for the user's password and running as root is a basic configuration of sudo, the de facto standard way to elevate privileges. Note that properly elevating privileges is tricky: did you remember to purge all environment variables that could affect your program? Sudo takes pains to do it safely. To allow user alice to run /usr/local/bin/myprogram as root with any arguments of her choice after typing her password, use the following line in the sudoers file (the sudo configuration file): alice ALL = (root) /usr/local/bin/myprogram To edit the sudoers file, run the command visudo. Alice will have to run sudo myprogram. If you want her to be able to type just the program name, hide this in a wrapper script. But note that Alice may prefer to run something like gksudo myprogram to get a GUI prompt. Many variations are possible, including forbidding the caller from passing arguments: alice ALL = (root) /usr/local/bin/myprogram "" or applying the entry to a group: %mygroup ALL = (root) /usr/local/bin/myprogram If your program needs to know who invoked it, sudo makes that available in the environment variables SUDO_UID and SUDO_USER.
User verification
1,654,423,942,000
I made 4 users on my server, but unfortunately I changed the password of the "first" user while configuring the server, but I don't know how I changed it. How can I see the password of users in root?
As root you can change any users password by using the "passwd" command followed by the username; passwd username This will then prompt you to enter the new password twice. To clarify there is no way to see an existing users password.
How can I see the password of another user in Linux?
1,654,423,942,000
I don't understand what's happening in this scenario. I changed the home directory of a user by editing the /etc/passwd file instead of using usermod -d. It worked: the default directory wasn't /home/nameoftheuser anymore, but /data/nameoftheuser, as I wanted. But something else changed: the prompt of the user. It isn't [\u@\h \W]\$ like it used to be. Now it's just bash 3.2 or something, and yet when I check $PS1, it's still [\u@\h \W]\$. $PS2 thru $PS4 are either empty or totally different from \v. Now, if I change /etc/passwd back to the default, the prompt returns to normal. Can anyone tell me why this happens?
Have you copied .bashrc file from the old home directory to the new one?. If you don't that is the problem, you don't have the environment variables set. Check that HOME is set there though, if it wasn't set there then it is being taken from /etc/bash.bashrc, so you should set the new one in the .bashrc that you are going to place in your new home.
Changing my default directory in passwd changes my prompt
1,654,423,942,000
Question 1 On Centos 6.5, I have a username called admin. How can I make it so the system logs in automatically? Question 2 How can I configure system to login as root user when there are other users on the system? Please don't bother me with security risks as this is a testbed station. There is no sensitive information that I need to worry about. Thank you.
For Question 1: Just edit /etc/gdm/custom.conf with your favorite editor. Then, under the [daemon] section, add 2 lines so it looks like the code below (change username to the username you want to use): [daemon] AutomaticLoginEnable=true AutomaticLogin=username
How do I remove login password for Centos6.5?
1,654,423,942,000
I would like to make shortcuts for gvfs mounts (I prefer to mount from the shell). For this, it is quite necessary/convenient not to have to enter the password for the ftp:// and sftp:// connections . Currently the only way I know is: echo 12345 | gvfs-mount sftp://[email protected]/ Even though I can make the file's rights 700 (or even 100), I'm not sure if it's reasonably safe. Is it worse than .netrc items? I know about ssh-copy-id, but I can't access shell on most of my sftp servers. Is there a better (standard) alternative to my approach? What do nautilus/caja do when they store the passwords?
You could use something like expect to provide the credentials each time you want to connect. It's not super secure but gives you what you want. #!/usr/local/bin/expect -- set timeout -1 spawn gvfs-mount {args} expect "User" send "joe\n" expect "Password:" send "xxxxx\n" expect eof Source: gvfs-mount specify username password
gvfs-mount auto password
1,654,423,942,000
I found on the AIX documentation some rules to set about passwords length : minlen Defines the minimum length of a password. The value is a decimal integer string. The default is a value of 0, indicates no minimum length. The maximum value allowed is PW_PASSLEN attribute. This attribute is determined by the minalpha attribute value added to the minother attribute value. If the sum of these values is greater than the minlen attribute value, the minimum length is set to the result. Note: The PW_PASSLEN attribute is defined in /usr/include/userpw.h. The value of the PW_PASSLEN attribute is determined by the system-wide password algorithm that is defined in /etc/security/login.cfg . The minimum length of a password is determined by the minlen attribute and should never be greater than the PW_PASSLEN attribute. If the minalpha attribute + minother attribute is greater than the PW_PASSLEN attribute, then the minother attribute is reduced to PW_PASSLEN attribute - minalpha attribute. But, for consistency, I need to set the max length for password to 12. I dont understand exactly how to configure the userpw.h to set this max at 12. There is my actual PW_PASSLEN : #define PW_PASSLEN ((__extension_status & _EXTENSION_C2)? \ max_pw_passlen():__get_pwd_len_max())
I believe you need to modify the value for MAXIMPL_PW_PASSLEN in /usr/include/userpw.h, from 256 to 12, but I would strongly suggest you read the documentation in that file, and test this on a non-critical box. If you have access, I'd suggest verifying this with IBM support.
Max password size in AIX 6.1
1,654,423,942,000
I am integrating my cakephp projects using jenkins. Right now, I am exploring the use of Phing. There is one task where I need to run service php5-fpm restart So far I tried to do this manually. I cannot do so unless i do it with sudo Please advise how I can execute this command without using sudo at all? I know there is an option where I can simply put the user that Phing is using inside sudoers and then not prompt for password, but for security reasons, that is not ideal. So I prefer to ask how to do this without getting prompted for password.
The last paragraph of your question is misleading, at least for me. If your goal is to find a way to invoke service as user Phing without getting asked for a passphrase I would do it with sudo. I will try to answer you question as I understand it, since I don't grasp what speak against the use of sudo in your case. Just add the line Defaults exempt_group=Phing to /etc/sudoers. This line adds the user Phing to a group on which sudo doesn't lay down path and password requirements. Further you have to add the line Phing ALL=(root) /full/path/to/service or alter an existing line of Phing, so that sudo grants him access to service. After that sudo service php5-fpm restart shouldn't ask Phing for a passphrase any longer. If you want it a bit more strict you can instead add the line Phing ALL=(root) NOPASSWD: /full/path/to/service without using exempt_group. Then you have to give sudo the full path of service (if it's not located in the standard paths), so command spoofing isn't possible. If you want to save some typing, you can also alias sudo service or sudo /full/path/to/service in your shell with service.
run 'service php5-fpm restart' without using sudo
1,654,423,942,000
I recently powered on some old notebook with Linux Mint 11 (Katya) installed, and I thought I remembered my user password, but turns out I didn't. So I reset that password using the instructions here. After doing that, I could login successfully with my new password, but right after that I got a series of error messages and was left with the plain Mint desktop: no program menu, no nautilus, no context menu; all I could do was restart or shutdown. Here are the errors, in order of appearance: Could not update ICEAuthority file /home/my_user/.ICEauthority There is a problem with the configuration server. (/usr/lib/libgconf2-4/gconf-sanity-check-2 exited with code 256) The panel encountered a problem while loading "OAFIID:GNOME_mintMenu". Do you want to delete the applet from your configuration? Of course, I always answered "Don't delete". Nautilus could not create the following required folders: /home/my_user/Desktop, /home/my_user/.nautilus. Before running Nautilus, please create these folders or set permissiones such that Nautilus can create them. When I restarted, I selected recovery mode from the GRUB menu and managed to login into a terminal and navigate to my home folder. When I ran ls there, all my files were gone, and in their place were a .desktop file and a README. It seems Mint realized I changed my password and took it as an attempt to hack into the system, so it encrypted the files in my home folder. Kudos to Linux security schemes, but what can I do now? Don't want to reinstall, I need those old files. I tried running ecryptfs-mount-private like the README suggests, but it asked me for a passphrase, and the new one doesn't work. Figures, it needs the old one.
It is absolutely essential that you record your randomly generated mount passphrase, without which it's impossible to recover your data. I can't stress that more strongly :-) You should write this down, or print it out and store it somewhere safe. Alternatively, you might consider using the zEscrow service from Gazzang. In Ubuntu (or Mint) 12.04 or later, just install the zescrow-client package, and run the zescrow command. It will prompt you for a zEscrow server and your login password, and then encrypt your mount passphrase and send it to a remote zEscrow server for safe keeping. You'll receive a nonced url, which you'll need to click on, authenticate with a Google OpenID account, and "claim" your upload. Here's a nice little how-to guide that I've written.
I reset my password and now I can login, but without nautilus or program menu
1,654,423,942,000
I created a shell alias that runs a simple shell script. The script is shown below, it sshs into another Linux machine: #!/bin/bash sshpass -p 'P@ssw0rd' ssh username@hostname I would like to encrypt the 'P@ssw0rd' section of the shell script.
Short answer: No, you cannot. Long answer: Shell scripts are human-readable files. As per the suggestion below, your question does not make proper sense. Suggestion: Use Public Key Authentication, see some of the found recipes.
How can I encrypt a password in a bash script?
1,654,423,942,000
How can I stop users form changing their passwords with PAM? Is this possible? PAM can enforce password strength and the like, but it can reject all changes?
Yes. I was able to stop it, by putting password required pam_deny.so In the /etc/pam.d/passwd.
Is it possible to stop users from changing their passwords with PAM?
1,654,423,942,000
I currently use ssh keys to connect to my server (Ubuntu 18.04). I would like to allow (in a specific, limited scope) the ability to login with passwords. Whenever I try, my passwords fail. below is a session where I set a password, then try to use it: ~ # id uid=0(root) gid=0(root) groups=0(root) ~ # passwd Enter new UNIX password: <helloworld> Retype new UNIX password: <helloworld> passwd: password updated successfully ~ # ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no [email protected] The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:AlFtwpK4EhhaMXP5aT6fuQM9u9RYPq/o/sLJXfz++jM. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. [email protected]'s password: <helloworld> Permission denied, please try again. I apologize if this is something obvious, I have no clue why the server accepts a new password, then accepts a password-based login to finally reject the credentials. EDIT: the sshd_config file I failed to add ~ # cat /etc/ssh/sshd_config | grep -v ^# | grep -v ^$ root@srv Port 22 PasswordAuthentication no ChallengeResponseAuthentication no GSSAPIAuthentication no UsePAM yes PrintMotd no UseDNS no AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server Match Address 192.168.10.0/24,192.168.20.0/24,127.0.0.0/8 PasswordAuthentication yes
The login failed, because there is no setting for PermitRootLogin in /etc/ssh/sshd_config which defaults to prohibit-password, which means password login is disabled for root. Adding PermitRootLogin yes to the Match block would allow root to login with password or public key authentication. Another option would be to use a different user.
Why would a ssh password-based login fail?
1,654,423,942,000
I ran a security scan in a RedHat Linux Server and got the following vulnerabilty: Incorrect System Default minimum password length or password complexity rules. Minimum password length should be set to 8. It should be set through pam_cracklib.so or pam_pwquality.so or pam_passwdqc.so. in the /etc/pam.d/system-auth I set the following line: password requisite pam_cracklib.so try_first_pass retry=5 minlength=8 but somehow I am still getting the same vulnerability. I don’t know which parameter am I missing in the file.
The man page for pam_cracklib lists the options the module accepts. Among them is what you're probably looking for: minlen=N The minimum acceptable size for the new password Note the abbreviated spelling, it's minlen, not minlength. The module might or might not log an error message for minlength if it doesn't recognize it. (One might be tempted to say that the module should fail if it's given an unknown option.) Note that minlength isn't exact, pam_cracklib gives so called "credit" for the password having e.g. upper case letters and digits. Check the documentation for ucredit, lcredit, ocredit and dcredit carefully. Also, it's probably a good idea to test the actual behaviour after configuring stuff like that.
password length with pam_cracklib.so
1,654,423,942,000
I'm planning a setup wherein users can only login to a machine via SSH, but will need their password for sudo commands (to avoid accidents so that there is a 'sanity check' prompt for a password, and to avoid compromised accounts such that even if someone fudges their way in with your pub-priv key, there's an extra challenge on root commands). Can I force a user to change their password when they first login (using a pub key) via SSH? I know I can use chage but I assume this is for physical logins and not remote logins.
The fact that you are using pubkey authentication to log in via SSH has nothing to do with their password. You are just configuring the ssh service to accept only that auth method. You can set their password expiration days to 0 with chage -d 0 [LOGIN] and the next time they log in they will be forced to change the password. BEWARE the first thing they will be asked when they connect through SSH will be their current password, then they can set up a new password. If there is no password set up for that user or they don't know it you have left them locked out of the system. An incorrect response to (current) UNIX password: will disconnect them immediately, and if they connect again they will be prompted that again.
Forced user password change when login over SSH
1,654,423,942,000
I tried to use my fingerprint reader on my laptop yesterday, installing fprintd ; it didn't work. I then removed all those packackages. I then realized Gnome (or non graphical session) doesn't ask for my password anymore at login screen, whether I set it on ON or OFF in the GUI parameters. Could anyone tell me how to change this setting in a terminal?
Run the following command: sudo pam-auth-update Select the 4 options then validate : [*] Unix authentication [*] Register user sessions in the systemd control group hierarchy [*] GNOME Keyring Daemon - Login keyring management [*] Inheritable Capabilities Management
Debian : how to set login behaviour (ask passsword)
1,654,423,942,000
I would like to compare multiple local files with their counterpart on a remote host, so I'd like to create a script like: ssh user@remote_host "cat remote_file1.txt" | diff - local_file1.txt ssh user@remote_host "cat remote_file2.txt" | diff - local_file2.txt ... ssh user@remote_host "cat remote_fileN.txt" | diff - local_fileN.txt The problem with such script is that it asks the password for each file. How to make it ask the password just once?
One way is to set up passwordless access (public key authentication), the other is to multiplex the connections. Create a configuration file in ~/.ssh/config with the following: Host remote_host User user ControlPath ~/.ssh/controlmasters/%r@%h:%p ControlMaster auto ControlPersist 5m Create a directory ~/.ssh/controlmasters/: mkdir -m 700 ~/.ssh/controlmasters/ And then when you run the script, it should ask only once for the password and all the other commands will be ran through the same, already authenticated, connection.
Run multiple diff between local and remote files
1,654,423,942,000
I want decrypt some gpg files, output into a file. But each time gpg ask password. for i in *.gpg; do echo $i>>~/t; gpg -d --batch $i >>~/t; done I test --multifile and --batch, those not as my wish.
Several ways: # gather the password into $P stty -echo; read -r P; stty echo; for i in *.gpg; do printf '%s\n' "$i" >> ~/t; printf '%s' | gpg -d --batch --passphrase-fd 0 "$i" >> ~/t; done # gather the password into $P stty -echo; read -r P; stty echo; for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase "$P" "$i" >> ~/t; done d=$(mktemp -d) # gather the password into a file named `p` stty -echo; cat > "$d/p"; stty echo for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase-file "$d/p" 0 "$i" >> ~/t; done rm -rf "$d"
How can I input password only once when gpg decrypt files in batch
1,654,423,942,000
I am really bad at remembering long passwords (but i can remember short random ones very well) and that is why i would prefer to be able to use password that are relatively short, but I'm afraid those would lower my system's security. In order to increase security over a short password for sudo I wanted to increase the delay between failed attempts. What would you consider a good guidelines for setting up the delay of sudo in pam relative to the passwords length? Do you consider this method to be problematic/unsecured or where do you think it can fail. If it is problematic what would be a better alternative to fight hard to remember long passwords. (the computer in hand is not a server and does not allow any kind of remote accesses with ssh/rdx or such, i use it as my personal desktop)
I didn't double check the implementation(*), but if the delay set by pam_faildelay gets implemented as a simple sleep, it will cause a single login attempt to take a longer time (thus annoying the user), but will not in itself limit the number of simultaneous login attempts. This somewhat undoes the intent of the delay, since someone trying to brute-force your password could simply open hundreds or thousands of login attempts simultaneously. Mostly they would spend their time sleeping, so the load on the system might not even be noticeable. What you need to do, is to limit the rate of login attempts, not the duration of a single attempt. For a network service, I'd suggest limiting it on the network side (say with iptables on Linux), but I don't have a solution to give for PAM. (The policy side of this, the password lengths and time limits, might be more suited to security.SE.) (* Because I didn't have the time. The delay appears to be set through PAM, and might go to the application to implement. But it's unlikely to be implemented as a busy loop, and any program that implements rate limiting)
What is a good balance between strong sudo password and a long delay
1,654,423,942,000
I have build a Linux From Scratch live CD and wrote an installer script for it. There is a step in that script in which I take an username and password from the user and create an user. The installed filesystem is mounted at /mnt The username is stored in $USER and password in $PASS To create the user, I use chroot /mnt useradd $USER -s /bin/bash -m To change the password, I use chroot /mnt echo "$USER:$PASS"|chpasswd But when I boot into the installed filesystem, I notice that the user has been created, but no password has been assigned. Where am I doing wrong?
Try this. Avoids the situation where chroot /mnt echo "$USER:$PASS"|chpasswd is failing due to the echo running within the chroot and the chpasswd running outside the chroot. echo "$USER:$PASS" >/mnt/foo chroot /mnt 'chpasswd </foo' rm /mnt/foo
Bash script to change password in chroot
1,654,423,942,000
Whats the mechanism behind sudo that stores the password for all subsequent calls to sudo?
To clarify, sudo uses a timestamp cache file (configured at build time with --with-rundir) and stores a timestamp entry (see ts_write() with it's struct timestamp argument) to the file. That struct is defined struct ts_cookie { char *fname; int fd; pid_t sid; bool locked; off_t pos; struct timestamp_entry key; }; where fname is set as the path to the cache file (and not the user's password) -- see timestamp_open() where it uses asprintf(&fname, "%s/%s", def_timestampdir, user) to set fname.
Mechanism behind password storage in sudo
1,654,423,942,000
After making a USB Live with Persistence stick, I tried to change root default password (using passwd) to no avail. Every time I reboot it resets to the default one. All other changes I've made (e.g. keyboard layout change, language change, update & upgrade all packages) do persist, except this one.
From Kali's forum, they suggest sed, I use a text editor as root but either will work. sed syntax is scary if you're not used to it. You can just comment out the line that is setting the password to a default value on boot. The config file is: /lib/live/config/0031-root-password Once this has been commented out by adding the # in front of the usermod command then your password will no longer be changed back to the default value every time you boot up.
How to change default root password for Live Kali Linux - USB persistence
1,433,346,714,000
I am attempting to configure Exim in such a way that clients who wish to relay email through the server must supply a single passphrase. The file /etc/exim4/conf.d/auth/30_exim4-config_examples contains the following configuration lines commented out: # plain_server: # driver = plaintext # public_name = PLAIN # server_condition = "${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}" # server_set_id = $auth2 # server_prompts = : # .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS # server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}} # .endif I'm not sure I fully understand exactly what is going on here. Why is server_prompts empty when the login_server example includes prompts for both a username and password? Shouldn't there be a prompt for a password here? Where is the password actually set? I fully intend to use TLS to secure communication between client and server - from what I understand, the last three lines in the snippet above causes the authentication method to be advertised only if TLS is enabled or AUTH_SERVER_ALLOW_NOTLS_PASSWORDS is set.
Leaving server_prompts as-is gives you the default (RFC compliant) behaviour, otherwise you might need to modify your clients to supply additional values. The password is looked up in the CONFDIR/passwd file, CONFDIR is equal to /etc/exim4 on Debian. Is your intention that all users use a common password? Then you could change the server_condition. Something like: server_condition = ${if {eq{$auth3}{mysecret}{yes}{no}} Do checkout the excellent exim documentation, e.g. here
Configuring Exim on Debian to authenticate using only a password?
1,433,346,714,000
I need a maintenance user which only requires a remote login. I'll preferably use only public keys to login into the account. I thought of just creating the user with useradd myuser, adding later the required public keys to its authorized_hosts file. useradd disables the password by default. Do I still require to run a passwd -l myuser to lock it? Any drawbacks here?
Yes, there are some drawbacks here. You are using password-less authentication to increase security. Since giving password will be a second door to login to your system. So in /etc/ssh/sshd_config PasswordAuthentication no RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys ChallengeResponseAuthentication no GSSAPIAuthentication no This changes will only authenticate with the public key, it will not ask password at any case. This will be a good security procedure to secure remote logins.
SSH key-only remote login, is disabling password a good practice?
1,433,346,714,000
i am trying to set a new password for linux Ubuntu 12.04,but on running command its giving something like this $passwd Changing password for ubuntu. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: Bad: new password is too simple Enter new UNIX password: i really don't understand why this is so....?
Solution for this we have to edit this file /etc/pam.d/common-password & we have to done changes like this password [success=1 default=ignore] pam_unix.so minlen=1 sha512
Change a Password is not successfull on ubuntu 12.04
1,433,346,714,000
Is there any way to put the password typed by user into a file (either in Unix or in expect). read -s -p "enter password" input echo $input > file Is the above code safe? I want to use that file as an input for password in my expect script Because I have tried this and I could see the password shown on the screen just for a sec with this expect code. set timeout 30 stty -echo send_user -- "Password for $username :" expect_user -re "(.*)\n" set timeout .000000001 set timeout 30 send_user "\n" set timeout 30 set password $expect_out(1,string) send -- "$password\r"
Whoever can read the file will get the password. That includes root, the user owning the file (or somebody impersonating them), and (depending on permissions) the users in the group or even everybody. Anyone who has a few minutes alone with the machine can reboot it with a LiveCD/LiveUSB and get at the file. And a long list of other possibilities. It is not safe. Perhaps enough for casual use, but not for anything serious. And consider that "I don't think it is critical" isn't enough, need to think any possible chain of uses of the privileges granted, other sites using the same password (or one constructed the same way), ...
How to safely put user typed password into a file?
1,433,346,714,000
I have worked for a while on making a BASH script to go through two lists and creating a command out of it. In the end it should execute the command and synchronize my ZFS server and ZFS backup server. Only pinnacle is that BASH cant actually insert a password when a command ask's for it. To my understanding this can be achieved with expect. The command is stored in $ExecuteSyncoid And would look like this /usr/sbin/syncoid <UserName>@<IP>:Storage/WallaBag Storage/Docker/WallaBag --compress none --sshcipher [email protected] --sshport <PortNumber> --sshkey </dest/to/keyfile> --no-privilege-elevation The password is stored in $PWD now i have to execute the expect from within BASH since im not really in the mood to try and recreate all the code in expect/tcl which i have never tried before. The expect part is Enter passphrase for key '<nameOfKey>' Now i dont understand tcl/expect But I have made the attempts so far and i just cant make it work even one time expect -c 'expect "Enter" { spawn $ExecuteCommand; send -- "$PWD\r"; interact }' expect -c 'spawn $ExecuteSyncoid; expect "Enter"; send -- "$PWD\r"; interact' syncoid command/password /usr/bin/expect - <<EOF spawn $ExecuteSyncoid expect "Enter" send -- "$PWD\r" EOF /usr/bin/expect <<EOD spawn $ExecuteSyncoid expect "Enter passphrase for key" send -- "$PWD\r" interact EOD /usr/bin/expect -c 'expect "Enter" { spawn $ExecuteSyncoid; send -- "$PWD\r" }' I Allso attempted to make a seperate script expect -f ./SynCoid-IterateThroughDataSets.exp $ExecuteSyncoid $PWD With the code #!/usr/bin/expect -f set ExecuteSyncoid [lindex $argv 0]; set PWD [lindex $argv 1]; spawn $ExecuteSyncoid expect "Enter" send "\$PWD\r" But unfortunately i cant figure out how to make expect see the $ExecuteSyncoid command as one consistent command. It wont execute it if i put it in quotos "" and if i dont have it in quotes the $ExecuteSyncoid bash variable is considered multiple arguments in expect. If anyone knows how to fix this, Or have an idea about what to do i would appreciate it. Would allso be great if i could sse the output of the expect command as it executes $ExecuteSyncoid Best Regards, Darkyere
I'm not going to review every variant. However shell variables don't expand within single quotes. Looking at the last variation: The shell part ExecuteSyncoid="/usr/sbin/syncoid <UserName>@<IP>:Storage/WallaBag Storage/Docker/WallaBag --compress none --sshcipher [email protected] --sshport <PortNumber> --sshkey </dest/to/keyfile> --no-privilege-elevation" PassWord="abc123" # Don't use PWD! expect -f ./SynCoid-IterateThroughDataSets.exp $ExecuteSyncoid $PassWord Because the variables are not quoted, they experience Word Splitting: expect script will see 13 arguments, not 2. Always quote your variables: expect -f ./SynCoid-IterateThroughDataSets.exp "$ExecuteSyncoid" "$PassWord" The expect part #!/usr/bin/expect -f set ExecuteSyncoid [lindex $argv 0]; set PWD [lindex $argv 1]; # this has nothing to do with the shell's PWD variable spawn $ExecuteSyncoid expect "Enter" send "\$PWD\r" Now that the shell variables are quoted, the expect variable ExecuteSyncoid is a single word that contains spaces. The spawn command will need that word expanded, so we'll use Tcl's Argument expansion syntax: spawn {*}$ExecuteSyncoid You don't want to escape the expect PWD variable when you send it: remove the first backslash send "$PWD\r" And unless you do something else in expect, after you send the password, the expect script will exit and that will kill the syncoid process. The last line of the expect script should be one of: if you, the human, need to interact with syncoid interact if you don't need to interact expect eof
Using expect in bash to execute a command with a password request
1,433,346,714,000
I use Fedora 34. I love what fprint is doing when it allows me to authenticate using my fingerprints on my ThinkPad's built-in fingerprint reader, but when I'm in my office, I like to dock my laptop and close the lid. I will use my external monitor, keyboard, and mouse during that time. However, there are times that I need to authenticate, and it asks for my fingerprint. Since the fingerprint reader isn't easily accessible, I'd rather simply switch to typing my password. Do I have to actually disable fprint in order to make authentication functional when I don't have access to the fingerprint reader, or is there a way to get it to fallback to password typing?
Sorry to disappoint you but, paraphrasing /usr/share/doc/fprintd-pam/README: Known issues: * pam_fprintd doesn't support entering either the password or a fingerprint
How can I type a password when fprint is enabled?
1,433,346,714,000
I have two systems Personal MacOS Laptop to be referred as system-Laptop having user laptopuser. It does not have "NAT" Server Linux to be referred as system-Server having user serveruser having static IP anyone can connect to. system-Server needs to send ssh commands to system-Laptop using a reverse SSH tunnel as the system-Laptop get dynamic IP and does not have "NAT" Below is how I setup ssh-keys and reverse SSH Step 1: Generated key pair for laptopuser on system-Laptop and copied the public key id_rsa.pub to self ~/.ssh/authorized_keys as well as on system-Server at <serveruserhomedir>/.ssh/authorized_keys Step 2: Generated key pair for serveruser on system-Server and copied the public key id_rsa.pub to self ~/.ssh/authorized_keys as well as on system-Laptop at <laptopuserhomedir>/.ssh/authorized_keys Note: Was able to successfully test this command on system-Laptop -> ssh serveruser@system-Server Step 3: Ran the below command on system-Laptop for reserve ssh tunnelling: ssh -N -R 3322:localhost:22 serveruser@system-Server Step 4: Ran the below command to connect to my Laptop from Linux server: ssh -p 3322 laptopuser@localhost The issue is the above command prompts for the password and once I provide laptopuser password it works. How can I get the above to work passwordless using ssh keys? Did I miss something? Doing this[reverse-ssh] for the very first time so unaware. Below is the debug output of step 4 ssh command: ssh -p 3322 laptopuser@localhost ....... ....... 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 134217728 blocks debug2: key: /home/serveruser/.ssh/id_rsa (0x56539b783370) debug2: key: /home/serveruser/.ssh/id_dsa ((nil)) debug2: key: /home/serveruser/.ssh/id_ecdsa ((nil)) debug2: key: /home/serveruser/.ssh/id_ed25519 ((nil)) debug3: send packet: type 5 debug3: receive packet: type 7 debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> 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: publickey,password,keyboard-interactive debug3: start over, passed a different list publickey,password,keyboard-interactive 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: /home/serveruser/.ssh/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: publickey,password,keyboard-interactive debug1: Trying private key: /home/serveruser/.ssh/id_dsa debug3: no such identity: /home/serveruser/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/serveruser/.ssh/id_ecdsa debug3: no such identity: /home/serveruser/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/serveruser/.ssh/id_ed25519 debug3: no such identity: /home/serveruser/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password 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: [serveruser@system-Server ~]$ ls -ltr /home/serveruser/.ssh/id_rsa -rw------- 1 serveruser serveruser 3243 Jan 15 21:01 /home/serveruser/.ssh/id_rsa
Firstly, the easiest way to copy SSH keys is by using ssh-copy-id command. Do this for both users. Secondly, to create a reverse tunnel, use the following command (executed on laptop): ssh -fnN -R 3322:localhost:22 serveruser@system-server Then lastly, connect to the tunneled service. No password will be asked if ssh-copy-id was completed earlier. Execute the following command on your system-server, to start a new SSH session from remote linux server to laptop. ssh -p 3322 laptopuser@localhost
Reverse SSH works but not passwordless. Getting password prompt
1,433,346,714,000
I was reading the shadow file structure explained here. I was wondering what happens if, perhaps for some type of error or wrong manual changes, the $id field representing the hashing algorithm is missing. The hash would be interpreted using a default system hashing algorithm? Or the account would be locked down for having no hashing algorithm associated?
If the has identifier is lost, the hash will be interpreted as coming from the DES crypt algorithm (the default). The real password won’t match, so the user will in effect be locked out from the account, but the account itself won’t be locked down — so for example root will be able to access it. It may be possible to find a password which will hash to the stored hash, interpreted as a DES hash, but that will only be possible for users who have read access to the file containing the hashes. See How to find the hashing algorithm used to hash passwords? for details of the hash identification.
Encrypted password with no linked algorithm
1,433,346,714,000
This user is a unpriviledged SFTP access user on our server, it was used during the stay-home order earlier this year due to Covid19, and I'm using it today to prepare some work for use tomorrow. Since I forgot its previous password, I reset it using the command sudo passwd <user>, and I wasn't able to login, I explicitly unlocked it using pw unlock and checked /etc/master.passwd, and confirmed I successfully changed the recorded password hash. Yet, I wasn't able to login using either sftp command remotely, or with login command during the admin ssh session. What could possibly be the cause of this? Update I copied password hash from another unpriviledged user to it and it still cannot login, that other unpriviledged user can login however.
Skimming through man page for passwd(5), I found the pwd_mkdb(8) command. Running: pwd_mkdb -p /etc/master.passwd solved the problem. In essence, the problem is that, /etc/master.passwd file didn't get updated into /etc/pwd.db and /etc/spwd.db. These 2 are "cached" database files in Berkeley database format (present for the presumed purpose of speeding up credential lookup). pwd_mkdb(8) is the system management command for generating "password database", which is the table of user information. I updated the server to 12.2-RELEASE last month, and forgetting to run the command is probably the cause.
Cannot login as a regular user on FreeBSD
1,433,346,714,000
I saw some abnormal thing after changing root password in linux. When I typed ls -al /etc/ | grep shadow after changing root password, the result is as below. -r-------- 1 root root 653 Mar 9 2018 gshadow -r-------- 1 root root 800 Jul 25 06:43 shadow -r-------- 1 root root 796 Jul 25 06:43 shadow- But sometimes the result is different with the above. -r-------- 1 root root 653 Mar 9 2018 gshadow -r-------- 1 root root ? Jul 25 06:43 nshadow -r-------- 1 root root ? Jul 25 06:43 shadow -r-------- 1 root root ? Jul 25 06:43 shadow- I'm just showing an example and don't remember exact size of those files (nshadow, shadow, shadow-). As my research, the /etc/nshadow is written by passwd when changing password, and then passwd just renames /etc/nshadow to /etc/shadow. But I don't know it is correct. Anyway, what is the /etc/nshadow?? and why this file is generated?? Please let me know the reason :(
Yes, the passwd command first writes the modified contents of the /etc/shadow file in full to /etc/nshadow, runs fsync() to ensure the nshadow file is actually written to the disk, and then renames /etc/nshadow to /etc/shadow. This is done to eliminate the possibility of ever having an incomplete file in place as /etc/shadow, even for the briefest time. POSIX specifications say that file rename operations within a single filesystem must be atomic, i.e. any other operations must only be able to see the rename operation as either "not started yet" or "fully completed", never in any kind of "in progress" half-way state. The pwconv command will also produce /etc/npasswd and /etc/nshadow when you use it to convert an archaic non-shadowed password file to the shadowed format. Some versions of pwconv may require the system administrator to move those files into place manually. If /etc/nshadow exists on your system, it might be a remnant of a pwconv command run at some time in the past... or it might be there because the rename("/etc/nshadow", "/etc/shadow") system call at the end of some password change operation failed. Such a failure would suggest possible filesystem corruption, or other problems. If the timestamp of the nshadow file is Jul 25 06:43, then you might want to find out what happened on the system at that time. Was there a problem of some sort that has since then been fixed, or did someone run the pwconv command for any reason? If the root password was changed using some sort of automation tool, you might want to find out exactly what that automation tool will actually do. Perhaps it will run pwconv for whatever reason.
Why the /etc/nshadow file remains after changing root password?
1,433,346,714,000
I'd like to store a value in an environment variable, but I don't want to do it like this VAR_NAME=secretvalue, because then it will be stored in the shell's history file. Is there a way to prompt me for the value, just like passwd does?
If you have the password in the clipboard, use xsel or xclip or pbpaste. See Any function copying from clipboard to a variable in Bash? Otherwise, assuming that the secret value doesn't contain any newlines (or any control characters or characters that you can't type): printf 'Password: ' IFS= read -r VAR_NAME Many shells let you pass the prompt directly to read: IFS= read -p 'Password: ' -r VAR_NAME If you don't want the secret to be visible on your terminal, see Reading passwords without showing on screen in Bash Scripts. Note that even without this, the password won't be saved anywhere once you clear your terminal.
Prompt for value to store in env variable
1,433,346,714,000
Brief: I would like to restrict port-forwarding from an SSH user identified by password. Explanation: In the following explanation of how to install a git server: https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server They explain that an SSH user with limited or no shell access could still use port-forwarding and some other OS services. At this point, users are still able to use SSH port forwarding to access any host the git server is able to reach. In this same text, they solve the problem by restricting SSH access in ~/.ssh/authorized_keys using no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty. I would like to do the same using password identification: I know that asymmetric cryptographic keys are usually more secure than password, but it also prevent accessing a server from "anywhere" without having your private key in the pocket. It seems (to me) that authorized_keys only applies to ssl key identification and not to password. How to limit port forwarding when using password identification? Note: Using CentOS 8
you can do the same in sshd.config but you need to disable shell access, because they still can run their own sshd see this question AllowTcpForwarding no AllowStreamLocalForwarding no GatewayPorts no PermitTunnel no
How to forbid port-forwarding for a password protected SSH user?
1,433,346,714,000
Computer Environment OS: Arch linux - Manjaro Shell: zsh AIM I'm trying to enable the following commands to not require a password input for my main user account: ab sudo systemctl stop NetworkManager sudo systemctl start NetworkManager FAILED ATTEMPT I've read and have tried to follow some of the online help and got so far as this by using sudo -i to create the file /etc/sudoers.d/ab with the following code: ab ALL=(root) NOPASSWD: sudo systemctl stop NetworkManager ALL=(root) NOPASSWD: sudo systemctl start NetworkManager TROUBLESHOOTING ATTEMPTS I've tried to make the following edits without success: changing root to ALL changing systemctl to /bin/systemctl deleting sudo Each time I make the edit and save, I cat /etc/sudoers.d/ab to check that changes were made, and I always open up a new terminal to try out the command, each time trying a combination of the following while still being asked for a password input: sudo systemctl start NetworkManager sudo /bin/systemctl start NetworkManager systemctl start NetworkManager /bin/systemctl start NetworkManager QUESTIONS Is starting a new terminal enough, or do I need to restart my whole system to initiate the changes? Or maybe I'm forgetting another step?
The lines in /etc/sudoers.d/ab should probably be like this: ab ALL=(root) NOPASSWD: /bin/systemctl stop NetworkManager ab ALL=(root) NOPASSWD: /bin/systemctl start NetworkManager With sudo and normal, locally stored sudoers.d files (and nothing advanced like sudoers information stored in a LDAP server), any changes to the sudoers files should take effect immediately, with no need to logout/login, start new terminals, or anything like that. Normally sudo will log both successful and failed attempts to use it, so you should look at the appropriate log file (usually either /var/log/secure or /var/log/auth.log, depending on distribution) for messages from sudo. Those messages will include the command the user is attempting to execute through sudo, in the exact form you'll need to write it into the sudoers file to allow it.
Trouble trying to set no password for certain cli commands in linux
1,433,346,714,000
Every time I restart the system and log in, a password prompt pops up: In most cases, this happens as soon as I open Chromium (it actually seems to freeze up the browser), and usually clicking on "Cancel" re-opens the prompt several (3-5) more times, which is extremely annoying. What is causing this and how can I disable it? Is there any way to identify the process behind it, e.g. using htop? Desktop environment is XFCE 4.
What is causing this? Answer from the manpages man chromium: --password-store=<basic|gnome|kwallet> Set the password store to use. The default is to automatically detect based on the desktop environment. basic selects the built in, unencrypted password store. gnome selects Gnome keyring. kwallet selects (KDE) KWallet. (Note that KWallet may not work reliably outside KDE.) How to disable it? run chromium with: --password-store=basic : chromium --password-store=basic You can create and alias : alias chromium='chromium /usr/share/applications/chromium.desktop' Then run: chromium from the terminal. Also you can edit the chromium configuration file: sudo nano /usr/share/applications/chromium.desktop Change the following line: Exec=/usr/bin/chromium %U to: Exec=/usr/bin/chromium --password-store=basic %U
What is this password prompt after logging in to Debian 9?
1,433,346,714,000
I'd like to show that entering passwords via read is insecure. To embed this into a half-way realistic scenario, let's say I use the following command to prompt the user for a password and have 7z¹ create an encrypted archive from it: read -s -p "Enter password: " pass && 7z a test_file.zip test_file -p"$pass"; unset pass My first attempt at revealing the password was by setting up an audit rule: auditctl -a always,exit -F path=/bin/7z -F perm=x Sure enough, when I execute the command involving read and 7z, there's a log entry when running ausearch -f /bin/7z: time->Thu Jan 23 18:37:06 2020 type=PROCTITLE msg=audit(1579801026.734:2688): proctitle=2F62696E2F7368002F7573722F62696E2F377A006100746573745F66696C652E7A697000746573745F66696C65002D7074686973206973207665727920736563726574 type=PATH msg=audit(1579801026.734:2688): item=2 name="/lib64/ld-linux-x86-64.so.2" inode=1969104 dev=08:03 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 type=PATH msg=audit(1579801026.734:2688): item=1 name="/bin/sh" inode=1972625 dev=08:03 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 type=PATH msg=audit(1579801026.734:2688): item=0 name="/usr/bin/7z" inode=1998961 dev=08:03 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 type=CWD msg=audit(1579801026.734:2688): cwd="/home/mb/experiments" type=EXECVE msg=audit(1579801026.734:2688): argc=6 a0="/bin/sh" a1="/usr/bin/7z" a2="a" a3="test_file.zip" a4="test_file" a5=2D7074686973206973207665727920736563726574 type=SYSCALL msg=audit(1579801026.734:2688): arch=c000003e syscall=59 success=yes exit=0 a0=563aa2479290 a1=563aa247d040 a2=563aa247fe10 a3=8 items=3 ppid=2690563 pid=2690868 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts17 ses=1 comm="7z" exe="/usr/bin/bash" key=(null) This line seemed the most promising: type=EXECVE msg=audit(1579801026.734:2688): argc=6 a0="/bin/sh" a1="/usr/bin/7z" a2="a" a3="test_file.zip" a4="test_file" a5=2D7074686973206973207665727920736563726574 But the string 2D7074686973206973207665727920736563726574 is not the password I entered. My question is twofold: Is audit the right tool to get at the password? If so, is there something I have to change about the audit rule? Is there an easier way, apart from audit, to get at the password? ¹ I'm aware that 7z can prompt for passwords by itself.
What's insecure is not read(2) (the system call to read data from a file). It isn't even read(1) (the shell builtin to read a line from standard input). What's insecure is passing the password on the command line. When the user enters something that the shell reads with read, that thing is visible to the terminal and to the shell. It isn't visible to other users. With read -s, it isn't visible to shoulder surfers. The string passed on the command line is visible in the audit logs. (The string may be truncated, I'm not sure about that, but if it is it would be only for much longer strings than a password.) It's just encoded in hexadecimal when it contains characters such as spaces that would make the log ambiguous to parse. $ echo 2D7074686973206973207665727920736563726574 | xxd -r -p; echo -pthis is very secret $ perl -l -e 'print pack "H*", @ARGV' 2D7074686973206973207665727920736563726574 -pthis is very secret That's not the main reason why you shouldn't pass a secret on the command line. After all, only the administrator should be able to see audit logs, and the administrator can see everything if they want. It is worse to have the secret in the logs, though, because they may be accessible to more people later (for example through an improperly secured backup). The main reason why you shouldn't pass a secret on the command line is that on most systems the command line is also visible to other users. (There are hardened systems where this isn't the case, but that's typically not the default.) Anyone running ps, top, cat /proc/*/cmdline or any similar utility at the right time can see the password. The 7z program overwrites the password soon after it starts (as soon as it's been able to make an internal copy), but that only reduces the window of danger, it doesn't remove the vulnerability. Passing a secret in an environment variable is safe. The environment is not visible to other users. But I don't think 7z supports that. To pass the password without making it visible through the command line, you need to pass it as input, and 7z reads from the terminal, not from stdin. You can use expect to do that (or pexpect if you prefer Python to TCL, or Expect.pm in Perl, or expect in Ruby, etc.). Untested: read -s -p "Enter password: " pass pass=$pass expect \ -c 'spawn 7z a -p test_file.zip test_file' \ -c 'expect "assword:" {send $::env(pass)}' \ -c 'expect eof' -c 'catch wait result' unset pass
Sniff password entered with read and passed as a command line argument
1,433,346,714,000
I'm using Pop!_OS (essentially ubuntu + tweaks with a gnome environment) and I've recently acquired a Mooltipass hardware password manager. This tool has the capability to manage SSH keys. I was wondering if it is possible and, if so, how, one might go about disabling password access to a desktop environment and using key-based authentication (SSH style) to log in instead?
The closest thing to what you are trying to do is: Install pamusb-tools and libpam-usb. Setup pamusb to use your mooltipass lsusb to find your device id sudo panusb-conf --add-device usb-name sudo panusb-conf --add-user username sudo nano /etc/pam.d/common-auth change the two lines after the #Here are the per-package modules, to read: auth sufficient pam_usb.so auth [success=1 default=ignore] pam_unix.so nullok_secure try_first_pass Then setup your other programs, to use the credentials on the mooltipass device. This will allow login with the mooltipass and also keep your other passwords handy. Reference: Here and Here The reason I think this is good enough is because if the person has your usb key they have it, regaurdless of if it is a crypto key or the uuid/name and serial number of the device it's self. The caveat comes from it not using the pin-code to unlock the device and then the computer. However if there is a device section that is available when the mooltipass is unlocked vs locked, you could just add the device that is available when mooltipass is unlocked and then your gold.
Use Key Based Login on Desktop Linux
1,433,346,714,000
I am using the linux password manager called "pass". Is there a way to set an expiry date on the stored passwords? I couldn't find any info on google or pass' man page. Do I have to resort to using another password manager to do this? I do use keepass for my smart phone (that's why I noticed a couple of my passwords expired). However, I prefer pass' cli for my desktop pc and I don't carry around all my passwords on my phone.
The pass password manager is, by its own manual's admission, a simple wrapper around GnuPG and Git, and does not support expiration dates on passwords. I would possibly suggest editing the password and adding that information to the password entry's text. This would obviously break scripts that relied on pass for extracting passwords (and that expects the password to be the only thing stored).
How to enable expiry date for passwords in pass?
1,433,346,714,000
I am using the following command to skip the 'password' check using 'echo' in ubuntu, echo $password | sudo -S apt-get install -y default-jdk I am using the following command to skip the 'password' check using 'echo' in centos, echo $password | yum -S -y install python-pip But the -S and echo is not working in CentOS rather, It is asking me to enter the password again. What is the way to skip asking for password using echo Or anything wrong in this command? NOTE: I can't use SSH-KEY EDITED: To make it clear, 1)I need to deliver a script to my customer, where the script will install python-pip as one of the part. The customer will provide the password as input for that script so I don't want the customer to enter the password during the execution of script. (i.e) I need to install the python-pip in the same machine without asking the user to enter the password. So as I tried in ubuntu I used the echo $password with -S, So I dont have any way to edit the sudoers also. So now Is there a way like echo $password / -S in centos?
I don’t see -S in yum’s man page.  Do you have some reason to believe that it means something? Maybe you mean echo $password | sudo -S yum -y install python-pip? echo $password is bad security.  Can you set up /etc/sudoers to allow the user to run apt-get and yum without asking for a password?
sudo echo in centos or redhat is not working [closed]
1,433,346,714,000
Is this correct to change the root password of MySql? echo "use mysql; update user set password=PASSWORD("NEWPASSWORD") where User='root'; flush privileges; quit;" | mysql -u root -pOLDPASSWORD I've seen this doc and a few others, but I don't find one "simple" definitive answer in a few lines. Also, should I stop mysql server before doing it, and restarting it after? (I tried mysql stop or mysql -uroot -pOLDPASSWORD stop on my Debian but none of them worked). Note: mysql -V gives mysql Ver 14.14 Distrib 5.5.40, for debian-linux-gnu (x86_64).
The proper command to do so is: mysql -uroot -poldp4ssw0rd -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newp4ssw0rd');" assuming that oldp4ssw0rd and newp4ssw0rd are the old and new passwords. You do not need to stop or restart the MySQL server at any time. In fact, the service needs to be running for you to connect to it and issue the command above. Note: this command solves your problem; however, in general it is not a good idea to pass passwords as command line arguments, as they could be seen by other logged-in users.
Change MySql root password
1,433,346,714,000
Recently changed my mail login password to a passphrase. .muttrc is set to call gpg to decrypt the file containing the password then awk the content into temp file and pass it to mutt (then delete the decrypted tmp file). The method worked perfectly with a single password. After having changed the password into a space separated phrase mutt now stops at the second word of the phrase with the error message: Error in ~/.muttrc, line 2: Word2: unknown variable where Word2 is the second word of the actual passphrase .muttrc is: set my_tmpsecret=`gpg -o ~/.crypt/.tmp -d ~/.crypt/.passwd.gpg` set my_gpass=`awk '{print $1,$2,$3,$4}' ~/.crypt/.tmp` set my_del=`rm -f ~/.crypt/.tmp` set imap_user="[email protected]" set imap_pass=$my_gpass set folder="imaps://[email protected]:993/" set spoolfile="+INBOX" set postponed="+[Gmail]/Drafts" set record="+[Gmail]/Sent Mail" set trash ="+[Gmail]/Trash" mailboxes = +INBOX set smtp_url = "smtp://[email protected]:587" set smtp_pass=$my_gpass set record="" set from="[email protected]" set realname="Some Body" set smart_wrap = yes set sort = 'threads' set sort_aux = 'last-date-received' set imap_check_subscribed #ignore "Authentication-Results:" ignore "DomainKey-Signature:" ignore "DKIM-Signature:" hdr_order Date From To Cc set date_format="%y-%m-%d %T" set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s" set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"' set header_cache = ~/.cache/mutt #set message_cachedir = "~/.cache/mutt" unset imap_passive set imap_keepalive = 300 set mail_check = 120 The same if $1,$2,...,$n is replaced by $0 Thanks
The .muttrc file is not a shell script, it's a configuration file that allows you to set particular variable that Mutt knows about. Mutt does not have a configuration variable called passwd, so it complains when you try to set it. Variables prefixed by my_ are ok though. Rather than going through a temporary variable (which doesn't work), set imap_pass directly to the value. After update to question: Your problem stems from your password being multiple space-separate words. In the Mutt configuration you can not have set my_variable=some words without proper quoting, set my_variable="some words" This means that your issue will be solved through set my_gpass="`awk '{print $1,$2,$3,$4}' ~/.crypt/.tmp`"
Mutt client can't sign in to mail server with decrypted passphrase
1,433,346,714,000
I have a zip file that I can't open since I forgot the password. I'm pretty sure of some parts of this password but I can't remember the variations I added to it. I tried fcrackzip but I can't see how to signify that I know parts of the password. To summarize: I know some parts of the password, example "hello", "world" and "shittypass". These parts can be in any order and not all of them may be used. Some additional small parts may appear, like 3 to 5 lower case letters. Do you know any software that can do that ?
Outline of method: Use a util like crunch to create a custom dictionary file. Run fcrackzip with that custom dictionary. Problems: Up to 3 strings mixed with anywhere from 3-5 lower case letters makes upwards of a trillion possible passwords. Just generating that dictionary will take a while. crunch permits using character-based wildcards, but its handling of custom strings is not as flexible. To solve this Q, grep, sed and sort also seem to be needed, any of which increases the time needed, i.e. hours, maybe days... Something like this would probably work: crunch 3 9 abcdefghijklmnopqrstuvwxyz123 | \ grep '[123]' | # at least one number per dict entry egrep -v '([123]).*\1' | # remove repeated numbers sed 's/1/hello/;s/2/world/;s/3/shittypass/' | # replace numbers with strings sort -u | \ fcrackzip -D -p /dev/stdin foo.zip Test case with a smaller problem set (one or two strings, and up to two lower-case letters, any order): echo foo > bar.txt # file to archive zip -P xhellobworld baz bar.txt # archive with password time crunch 2 4 abcdefghijklmnopqrstuvwxyz12 | \ grep '[12]' | egrep -v '([12]).*\1' | \ sed 's/1/hello/;s/2/world/' | \ sort -n | fcrackzip -u -D -p /dev/stdin baz.zip Output: Crunch will now generate the following amount of data: 3163440 bytes 3 MB 0 GB 0 TB 0 PB Crunch will now generate the following number of lines: 637392 PASSWORD FOUND!!!!: pw == xhellobworld real 0m5.942s user 0m2.240s sys 0m1.040s
Crack zip file with parts of passwords known
1,433,346,714,000
I know this is a bit weird. I generated ssh keys on my server, but I still want to force clients to enter a passphrase to be able to SSH to the server,even if they have the key. Is that even possible? Can I set a password on top of the key, and force clients to use both to SSH?
Without knowing the version of OpenSSH you're running, or the distro, it's difficult to answer. However, there are many ways to achieve this. One such way, if you're running a recent version of OpenSSH, is to use the AuthenticationMethods directive in you /etc/ssh/sshd_config file. Example: AuthenticationMethods publickey,keyboard-interactive
Force ssh to ask for password and public key
1,433,346,714,000
This is not a duplicate of this question. I log into a remote server using ssh with a key pair (no password needed). On the remote server, there's a script of mine needing a password for something else. When I log in and execute the script, I get prompted, enter the password and everything is fine: my-local> ssh my-remote my-remote> ./my-script Password for something else: *** OK my-remote> exit When I try to do it in a single step, I get an error like my-local> ssh my-remote ./my-script fatal: could not read Password for .... No such device or address I wouldn't really mind entering the password, if I only could. However, as a side question, I'd like to know if it's possible to pass the PW from "my-local" in a secure way (I don't want to store it in the script on "my-remote"). Both servers are Ubuntu 16.04.
The tool is reading from tty and if you specify a command to the ssh, it does not allocate you a TTY on the remote server and therefore it will fail. You can force ssh to allocate you TTY on the remote server using -t switch. ssh -t my-remote ./my-script should do the job for you.
Pass password to a script running over ssh
1,433,346,714,000
how can i switch user using su command and adding password from file ? i want to make a script which will automaticly switch the user, having the user and the password ,instead of manually typing the password ? P.S. I don't have super user rights.
Typically programs like su require passwords to be entered on the terminal and can't be bypassed. The root user doesn't need to enter a password to switch to another, so it's common to see solutions like sudo su user. However we might be able to cheat. If you have the expect command on your system then we can fake typing the password #!/usr/bin/expect -f set user [lindex $argv 0] set password [lindex $argv 1] spawn /bin/su $user expect "Password:" send "$password\r"; interact With this program you can do ./autosu username password eg % autosu root imnottellingyou spawn su root Password: [root@server /]# It's not normally a good idea to do this exact thing, though, 'cos the password will appear in your shell history when you type it on the command line. But if you have the password inside a script or data file then it doesn't matter too much! You should be able to modify this simple example to meet your needs. If you don't have expect installed then it gets harder; ask your admin to install it, or compile it from source and run it from your directory!
Switch user using password from file
1,468,991,570,000
I'm currently having issues running adding, deleting and modifying Linux users. Reasonably new to Linux so pretty sure I have tried everything to resolve this. [root@device01 /]# useradd testuser useradd: cannot lock /etc/passwd; try again later. Attempting to change an existing users password also returns the follows: [root@device01 ~]# passwd olduser Changing password for user olduser. New password: BAD PASSWORD: it is based on a dictionary word Retype new password: passwd: Authentication token manipulation error Have checked to make sure there are no lock files (/etc/gshadow.lock, /etc/shadow.lock, /etc/passwd.lock and /etc/group.lock) I have tried running the following to make sure that the filesystem was mounted correctly which also failed: [root@device01 /]# mount -o remount,rw / can't create lock file /etc/mtab~60598: No space left on device (use -n flag to override) [root@device01 /]# Checking the diskspace usage doesn't reveal anything (unless I'm missing something) [root@device01 /]# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup-lv_root 51606140 6953044 42031656 15% / tmpfs 3881396 0 3881396 0% /dev/shm /dev/mapper/ddf1_4c5349202020202080862925000000004711471100001e78p1 495844 120559 349685 26% /boot /dev/mapper/VolGroup-lv_home 112173808 20244156 86231504 20% /home /dev/mapper/ddf1_4c53492020202020808629250000000047114711000028a0p1 1032131696 382893688 596808680 40% /backup /dev/sde1 1922828276 1011928116 813226168 56% /mnt/BackupDrive The server has not been rebooted for around two weeks, and ignoring the golden rule would prefer to use this as a last resort. Version information is as follows: [root@device01 /]# uname Linux [root@device01 /]# lsb_release LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Is there anything else I can try or am possibly missing? Edit #1 [root@device01 /]# mount /dev/mapper/VolGroup-lv_root on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/mapper/ddf1_4c5349202020202080862925000000004711471100001e78p1 on /boot type ext4 (rw) /dev/mapper/VolGroup-lv_home on /home type ext4 (rw) /dev/mapper/ddf1_4c53492020202020808629250000000047114711000028a0p1 on /backup type ext4 (rw) /dev/sde1 on /mnt/BackupDrive type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) Edit #2 [root@device01 ~]# strace useradd testuser execve("/usr/sbin/useradd", ["useradd", "testuser"], [/* 28 vars */]) = 0 brk(0) = 0x7fabaf304000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae831000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=48359, ...}) = 0 mmap(NULL, 48359, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fabae825000 close(3) = 0 open("/lib64/libaudit.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260%@\3243\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=115536, ...}) = 0 mmap(NULL, 2208304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabae3f7000 mprotect(0x7fabae40e000, 2093056, PROT_NONE) = 0 mmap(0x7fabae60d000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fabae60d000 close(3) = 0 open("/lib64/libselinux.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0PX\300\3163\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=124624, ...}) = 0 mmap(NULL, 2221912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabae1d8000 mprotect(0x7fabae1f5000, 2093056, PROT_NONE) = 0 mmap(0x7fabae3f4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7fabae3f4000 mmap(0x7fabae3f6000, 1880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fabae3f6000 close(3) = 0 open("/lib64/libacl.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\36\200\3213\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=33816, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae824000 mmap(NULL, 2126416, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabadfd0000 mprotect(0x7fabadfd7000, 2093056, PROT_NONE) = 0 mmap(0x7fabae1d6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fabae1d6000 close(3) = 0 open("/lib64/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\356A\3153\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1926520, ...}) = 0 mmap(NULL, 3750152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabadc3c000 mprotect(0x7fabaddc6000, 2097152, PROT_NONE) = 0 mmap(0x7fabadfc6000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x7fabadfc6000 mmap(0x7fabadfcb000, 18696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fabadfcb000 close(3) = 0 open("/lib64/libdl.so.2", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\300\3153\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=22536, ...}) = 0 mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabada38000 mprotect(0x7fabada3a000, 2097152, PROT_NONE) = 0 mmap(0x7fabadc3a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fabadc3a000 close(3) = 0 open("/lib64/libattr.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\23\300\3203\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=21152, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae823000 mmap(NULL, 2113888, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fabad833000 mprotect(0x7fabad837000, 2093056, PROT_NONE) = 0 mmap(0x7fabada36000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fabada36000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae822000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae820000 arch_prctl(ARCH_SET_FS, 0x7fabae8207a0) = 0 mprotect(0x7fabada36000, 4096, PROT_READ) = 0 mprotect(0x7fabadc3a000, 4096, PROT_READ) = 0 mprotect(0x7fabadfc6000, 16384, PROT_READ) = 0 mprotect(0x7fabae1d6000, 4096, PROT_READ) = 0 mprotect(0x7fabae3f4000, 4096, PROT_READ) = 0 mprotect(0x7fabae60d000, 4096, PROT_READ) = 0 mprotect(0x7fabaea4b000, 4096, PROT_READ) = 0 mprotect(0x7fabae832000, 4096, PROT_READ) = 0 munmap(0x7fabae825000, 48359) = 0 statfs("/selinux", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=12901535, f_bfree=11155729, f_bavail=10500369, f_files=3276800, f_ffree=0, f_fsid={1688549107, 1017566797}, f_namelen=255, f_frsize=4096}) = 0 brk(0) = 0x7fabaf304000 brk(0x7fabaf325000) = 0x7fabaf325000 open("/proc/filesystems", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tb"..., 1024) = 317 read(3, "", 1024) = 0 close(3) = 0 munmap(0x7fabae830000, 4096) = 0 socket(PF_NETLINK, SOCK_RAW, 9) = 3 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 open("/usr/lib/locale/locale-archive", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=99158576, ...}) = 0 mmap(NULL, 99158576, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7faba79a2000 close(4) = 0 open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 4 read(4, "65536\n", 31) = 6 close(4) = 0 mmap(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae79f000 access("/etc/shadow", F_OK) = 0 access("/etc/gshadow", F_OK) = 0 open("/etc/default/useradd", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0600, st_size=119, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(4, "# useradd defaults file\nGROUP=10"..., 4096) = 119 socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5 connect(5, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(5) = 0 socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5 connect(5, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(5) = 0 open("/etc/nsswitch.conf", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=1688, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae82f000 read(5, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1688 read(5, "", 4096) = 0 close(5) = 0 munmap(0x7fabae82f000, 4096) = 0 open("/etc/ld.so.cache", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=48359, ...}) = 0 mmap(NULL, 48359, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7fabae793000 close(5) = 0 open("/lib64/libnss_files.so.2", O_RDONLY) = 5 read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360!\0\0\0\0\0\0"..., 832) = 832 fstat(5, {st_mode=S_IFREG|0755, st_size=65928, ...}) = 0 mmap(NULL, 2151824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x7faba7794000 mprotect(0x7faba77a0000, 2097152, PROT_NONE) = 0 mmap(0x7faba79a0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0xc000) = 0x7faba79a0000 close(5) = 0 mprotect(0x7faba79a0000, 4096, PROT_READ) = 0 munmap(0x7fabae793000, 48359) = 0 open("/etc/group", O_RDONLY|O_CLOEXEC) = 5 fcntl(5, F_GETFD) = 0x1 (flags FD_CLOEXEC) fstat(5, {st_mode=S_IFREG|0644, st_size=2595, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae82f000 read(5, "root:x:0:\nbin:x:1:bin,daemon\ndae"..., 4096) = 2595 close(5) = 0 munmap(0x7fabae82f000, 4096) = 0 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7fabae830000, 4096) = 0 open("/etc/login.defs", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=1816, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(4, "#\n# Please note that the paramet"..., 4096) = 1816 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7fabae830000, 4096) = 0 socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4 connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) close(4) = 0 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=4671, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(4, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 4096 read(4, "b:x:560:501::/home/claireb:/bin/"..., 4096) = 575 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7fabae830000, 4096) = 0 open("/etc/group", O_RDONLY|O_CLOEXEC) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=2595, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(4, "root:x:0:\nbin:x:1:bin,daemon\ndae"..., 4096) = 2595 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7fabae830000, 4096) = 0 open("/etc/.pwd.lock", O_WRONLY|O_CREAT|O_CLOEXEC, 0600) = 4 fcntl(4, F_GETFD) = 0x1 (flags FD_CLOEXEC) rt_sigaction(SIGALRM, {0x7fabadd2b110, ~[], SA_RESTORER, 0x7fabadc6e6a0}, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [], 8) = 0 alarm(15) = 0 fcntl(4, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0 alarm(0) = 15 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigaction(SIGALRM, {SIG_DFL, [], SA_RESTORER, 0x7fabadc6e6a0}, NULL, 8) = 0 getpid() = 63618 open("/etc/passwd.63618", O_WRONLY|O_CREAT|O_EXCL, 0600) = -1 ENOSPC (No space left on device) close(4) = 0 open("/usr/share/locale/locale.alias", O_RDONLY) = 4 fstat(4, {st_mode=S_IFREG|0644, st_size=2512, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabae830000 read(4, "# Locale name alias data base.\n#"..., 4096) = 2512 read(4, "", 4096) = 0 close(4) = 0 munmap(0x7fabae830000, 4096) = 0 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/locale/en_US.utf8/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/locale/en_US/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/locale/en.UTF-8/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/locale/en.utf8/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/locale/en/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory) write(2, "useradd: cannot lock /etc/passwd"..., 51useradd: cannot lock /etc/passwd; try again later. ) = 51 exit_group(1) = ? Edit #3 [root@device01 ~]# df -i / Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/VolGroup-lv_root 3276800 3276798 2 100% /
can't create lock file /etc/mtab~60598: No space left on device (use -n flag to override) open("/etc/passwd.63618", O_WRONLY|O_CREAT|O_EXCL, 0600) = -1 ENOSPC (No space left on device) It's definitely a disk space problem. Most filesystems have two limits: a limit on file contents, and a limit on the number of files — the size of the inode table. Since df / shows plenty of space left, by a process of elimination, the problem must be with the number of inodes. You can check with df -i /. With ext4 (the most common filesystem type on Linux), there is no way to increase the number of inodes on an existing filesystem. If you have a lot of small files somewhere (How to report number of files in all subdirectories? may help), try to move them to another filesystem. You can shrink an ext4 filesystem to make room for another filesystem with more inodes (you can set the number of inodes when you create the filesystem) but this can't be done while the filesystem is mounted.
Unable to add or delete users
1,468,991,570,000
I have written an expect script to automate the login process for ssh. My user account has rsa keys setup but once I log in I want to switch to root but the remote server is hanging on the password. I can see the script feeding the password to the remote server, albeit its visible, which is another thing I'd like to know if I can hide. But can someone tell me why this is hanging? #!/usr/bin/expect spawn ssh <server> su - expect "Password" send "MyPassword\r" interact It just sits there at this screen: Password: "password" With the cursor right below it which blinks continously. In /var/log/secure I have compared the lines of my scripted login attempt with a normal one where I manually get root. Script su: Jun 7 15:17:50 <server> su: pam_unix(su-l:session): session opened for user root by (uid=1000) Manual su: Jun 7 15:18:48 <server> su: pam_unix(su-l:session): session opened for user root by <user>(uid=1000) The only thing is that I see different is the manual login has my username listed. I have tried changing up the command to : spawn ssh <server> su - root spawn ssh <server> sudo su But neither one works. How can I get this going?
In the script I had to pass it the -t flag to force tty allocation: spawn ssh -t <server> su - It now works as expected.
script ssh login to server and pass root password
1,468,991,570,000
Studying the CentOS/RHEL sysadmin manual, I can't understand if there are or what are the differences between these commands.
passwd is a traditional unix command. lpasswd appears to belong to the libuser project, "a standardized interface for manipulating and administering user and group accounts." % ls -li =passwd =lpasswd 3149052 -rwsr-xr-x. 1 root root 30768 Feb 17 2012 /usr/bin/passwd 3155939 -rwxr-xr-x 1 root root 33240 Jul 10 2015 /usr/sbin/lpasswd % rpm -qf =passwd passwd-0.77-4.el6_2.2.x86_64 % rpm -qf =lpasswd libuser-0.56.13-8.el6_7.x86_64 % rpm -q --queryformat='%{URL}\n' libuser https://fedorahosted.org/libuser/ lpasswd lacks a setuid bit, so that's interesting.
What's the difference between lpasswd and passwd commands?
1,468,991,570,000
I'm attempting to write a script that will login to a remote server via ssh, without popping up a password prompt to the user (the remote server is not under my control, and they won't allow me to use key authentication). Normally I just pass the password into the command, and this works fine, but every 3 months, they want me to change the password, so it pops up a password prompt, which breaks my script. I've tried capturing the password prompt via STDOUT and STDERR, but it is not getting sent to either one. I'm not sure how to capture the prompt, or send the response back. As a test, I've tried just doing ssh without a password, and get the same basic behavior. ssh [email protected] 2> /dev/null still shows the password prompt, e.g. so does ssh -T and ssh -t any tips would be appreciated. Cheers
Use expect, or an implementation of such in another language (Wikipedia has a list of these at present). expect was designed for precisely this sort of terminal automation task. The quickest way to bootstrap this automation might run along the lines of: autoexpect ssh [email protected] And then mash the keyboard as necessary, exit ssh, and inspect the resulting script file.
How to login to an ssh server and capture prompts programmatically?
1,468,991,570,000
Is is possible to change root's password using setuid? What I tried is writing a simple program which calls system("passwd root") owned by root and its setuid bit is set but it didn't work. The output is: You may not view or modify password information for root.
In your program, you probably overlooked making the real and effective uid set to the same value. Gids also should match root's gid. Something like this: setuid(geteuid()); setgid(getegid()); See for example sue (a simple setuid/setgid wrapper).
Changing root's passwords using setuid
1,468,991,570,000
I'm a Windows user trying to wrap my head around Linux, and lately that means following behind people on Raspberry Pi projects. I've noticed that there are applications that require me to enter the username and password into their config file for them to access things as that user. Samba/CiFS/NTFS-3g and Deluge being examples. In Windows, things like services (aka daemons) can run under the Local System account (different links), or a variety of other accounts. It seems strange, and inherently insecure, to put passwords in text files as plain text. Yet, I'm always hearing about how Linux is supposed to be more secure than Windows. How can you securely pass credentials to random applications in Linux/Raspbian? Are the security models so different that this is mitigated in some other manner? How do I keep track of (or update) what programs I put in a static password? Am what I am looking for a "keyring"? Something described here. This question is similar, but asks about the OS and I'm referring to applications.
Here's the thing. It's based on how the application works or how it was developed. It usually stops there. You can't blame Linux (or in this case, any unix-like OS) for those things. You'll find some applications out there that say the password can be in cleartext OR hashed in say, sha256. This is normally for compatibility reasons, as you may find out later in something else you may learn to setup. You bring up Samba, and that's a good example of a situation where you think you could have an encrypted password or maybe a "store" where the passwords sit. That is not the case with Samba. What happens with Samba is when a client is communicating with a server or a workstation's share, it HAS to send the password in clear text. The CIFS daemon nor the Samba server can perform encrypted password exchanges. If the connection is encrypted, then you are somewhat "fine" in this regard. Newer versions of the SMB protocol do allow encrypted connections. However, keep in mind too, files that have credentials (like config files) should be heavily dropped in permissions (say 600). A samba mount that always needs to be there on boot and put in /etc/fstab can be pointed to a "credential" file. It's cleartext, but can sit in /root, which means no user can see it. Only an administrator can, because /root is 700. But again... this is based on the application you've installed or you're setting up. Look at OpenLDAP for example. When you configure the directory manager's password, you have to use slappasswd. It generates a {SSHA} string that you use in the configuration. And the configuration files cannot be viewed by a non-privileged user. /etc/openldap/slapd.d is 750, the files are 600 down the tree. Keyrings are very specific to the desktop environment you're in. GNOME has GNOME Keyring, KDE has KWallet, for example. The "security" comes down to many other factors: File System Permissions, SELinux (if applicable), Firewall capabilities, chroot jailing (specific applications, bind is an example), application security, tcp wrappers, and much much more.
Plain text passwords and application authentication compared to Windows
1,468,991,570,000
so I booted up an old Linux Mint machine today and I can't seem to remember the password. So I wanted to reset the password using the instructions on Mint's website but when I hold shift the GNU GRUB boot menu does not seem to come up. It just asks me for my password then shows me the login screen. To clarify, I know the system password but not the login password. I initially assumed it was because I was using a USB keyboard at first but that does not appear to be the problem as it is recognizing the keyboard immediately and I can enter Bios. Any help would be appreciated. Password Reset Page - http://community.linuxmint.com/tutorial/view/339
You have to download in other machine a live distro (if you have 64bit , download 64 and if you have 32bit download 32 bit), Then step by step do the following steps: Boot with your live cd create a dir mount your old linux on your dir chroot dir Now , you have old linux and you can change password, and manipulate grub and run grub-install
Can't enter GNU GRUB boot menu!
1,468,991,570,000
I'm using a script to download files in two steps: First, I'm downloading a file containing a list of files from a server to my host machine using rsync. Then, I'm using rsync to download the actual files (quite a lot) given in the list from the server to my host computer. The problem is that the script is asking for the password regularly i.e. it keeps on asking for the password of my account on the server. The files are downloading without any problem, so I'm guessing that the for loop is causing the issue as it is asking for the password while downloading every single file in the list from the server. If I'm correct then what could be a possible solution so that the script will ask for the password only once? if I'm wrong then please do correct me. NOTE: BTW, key based authentication is not allowed. #!/bin/bash rsync --partial -z --remove-source-files server:~/list ~/. for i in $(cat ~/list) do rsync --partial -z server:/some/location/$i ~/someplace/$i done
Your theory sounds right to me. Each time through the for loop when you invoke rsync, it's reconnecting to the server and causing you to be re-prompted. Rather than loop through the file, ~/list using for you could give this list directly to rsync using the --files-from= switch. Example $ rsync --partial -z --files-from=/some/list server:/some/location/ ~/someplace/
Repetition of password while rsync-ing files?
1,468,991,570,000
I have 3 users in "production" group: John, Steve and Bob. In "sales" group are: Sam and Jack. Now, I would like to give John permition to change passwords of all users but only in "production" group, so he will be unable to make any changes to Sam and Jack. In my /etc/sudoers file I have alias for all users in "production" group: User_Alias PRODUCTION = %production And the problem is I have no idea how to write this: john ALL =(root) /usr/bin/passwd steve, (root) /usr/bin/passwd bob, (root) /usr/bin/passwd jack ... using my PRODUCTION alias, so if there is someone new added to this group, there will be no need to add him manually to sudoers file too. I've tried something like this in many variations: john ALL =(root) /usr/bin/passwd PRODUCTION but it doesn't work and at this moment I have no more ideas. I will appreciate any clues, thanks a lot!
This is too complicated for sudoers. You have to write a script which checks whether the user belongs to this group and calls passwd if so. sudoers must then be configured so that john can run this script as root. Of course, the path to this script must be writable only for root. #! /bin/bash group="groupname" test $# -ne 1 && exit 2 user="$1" if id "$user" | grep -qF "(${group})"; then echo passwd "$user" else echo "User '${user}' is not in group '${group}'." fi called as ./testscript username
sudoers file and passwd only for selected group
1,468,991,570,000
Using Samba, as a domain controller, I need to add Windows machines as users (in /etc/passwd), and to the Samba database as a machine. In the /etc/passwd file, I noticed about half the machines have a shell of /bin/sh, the other half have /bin/false. I would prefer them all to be /bin/false, but only if that's acceptable, and the recommended way. Is there any security or functional restrictions to the machine account having /bin/false instead of /bin/sh? Currently, we are using Samba 3 on Debian Wheezy. An example set of entries below: cla-teach-54$:x:1367:1386::/home/cla-teach-54$:/bin/sh cla-teach-55$:x:1369:1388::/home/cla-teach-55$:/bin/sh cla-teach-56$:x:1562:1583::/home/cla-teach-56$:/bin/sh cla-teach-57$:x:1846:1864::/home/cla-teach-57$:/bin/false cla-teach-58$:x:1948:1960::/home/cla-teach-58$:/bin/false cla-teach-59$:x:1949:1961::/home/cla-teach-59$:/bin/false (note: none of the home folders exist)
It's not only acceptable, but also preferable to have them have /bin/false as a login shell, else someone could actually long onto the system and get shell access. Remember to pass -s /bin/false to useradd to set the login shell to /bin/false
Default Shell for Samba Machine Accounts
1,468,991,570,000
The command I'm talking about is this: mysqldump -u root -p DB | mysql -u root -p DB2 And here's the output: Enter password: Enter password: MYPASS As far as I can tell, after I enter first password supposedly mysqldump turns on echo, and as a result the second password is echoed. Now that I think about it, how do they even manage to both read the password?
I can answer the question of "how do they even manage to both read the password?" A device file named /dev/tty exists. Linux (and more modern Unix) kernels arrange for /dev/tty to be different for every process that has a controlling TTY. That's all of the interactive processes, you'd have to go out of your way to write a program that doesn't have a controlling TTY. The "TTY" column of ps -l -p $$ will show you what your shell's TTY is. ps -el "TTY" column will show you the controlling TTY of all processes. You can think of /dev/tty as a way to get what would ordinarily be stdin, but from the keyboard associated with the controlling TTY. You can try this out with the command cat < /dev/tty > spork in an Xterm window. Whatever you type, up to the terminating control-D, will end up in file "spork". A lot of FTP and SSH clients use /dev/tty for password input, to avoid having a password show up in the environment or other crannies. Interactive clients can do open("/dev/tty", O_RDWR) no matter what the actual controlling TTY is, and get a file descriptor that in essence, is connected to the keyboard. Various system calls can be used to turn off echoing. You can test this by using a bash shell Xterm and running stty -echo. You'll have to type blind, but commands like ls, ps, etc clearly get to the shell and work. You can turn TTY echoing back on via stty echo. It appears (as per Rahul Patil above), that you can set a password in a file, .my.cnf. That file could include these lines: [client] password="my_password" or maybe something like: [mysql] password="my_password" user=root The .my.cnf file appears to be extremely flexible in specifying parameters and values common to many clients of MySQL.
How do I avoid echoing password (two simultaneous prompts)?
1,468,991,570,000
Basically I have a bash script that fetches data from my server to perform a backup. As it is now I have to start that script manually, enter the password, and then wait for it to finish. I would like to set up a cronjob that handles the backup. But I really don't know how to handle the password in a cronjob. Also I can't use keys for this, because my provider does not provide the mechanisms I need to configure them. I have SSH access to my home folder, but in my home folder I don't have write access except for the http(s)docs directory. So I can't create the necessary ~/.ssh/ directory and its contents for login via keys.
This is the command I use to backup to another machine: rsync -av -e "ssh -i /root/ssh-rsync-valhalla-key" \ --exclude lost+found \ --delete-before \ /mnt/backup/ \ [email protected]:/cygdrive/r/\!Backups/Niflheim & So you can use the -i to pass a keyfile to ssh. Of course, in your example, that means the keyfile itself will be sharable via HTTP if anybody ever figures out the filename.
Using rsync in a cronjob when a password is needed
1,468,991,570,000
I want to create system user without password and home directory. I found some similar solution but not properly get my answer. I am using a centos machine. in ubuntu: adduser mprobe --disabled-password --system --no-create-home --group its working but in centos it says disable-password not found. thanks in advance.
AFAIK adduser isn't a coreutils command, it's just a convenience script, so it may vary drastically from distro to distro. A quick Google search yields, that password could be disabled for an existing user with passwd -d <username>. So my recommendation would be to: sudo -s # Enter a root shell then: adduser mprobe --system --no-create-home --group # Create the user in question passwd -d mprobe # Delete its password exit # Drop root privileges
Create a system user without password and home directory on Centos machine
1,468,991,570,000
Here's info on the pass: https://www.passwordstore.org My key point is, that I would like to pass the passphrase key at the command line. However, the topic and solutions related to this question that I could find, are not working in my case. When I have examined the code of Pass, I have found a parameter called PASSWORD_STORE_GPG_OPTS. As far as I can see, it should be possible to use it to pass --pinentry-mode=loopback --passphrase "<password_here>" to gpg executed by Pass. The code fragment that executes it is here: #Line 9 GPG_OPTS=( $PASSWORD_STORE_GPG_OPTS "--quiet" "--yes" "--compress-algo=none" "--no-encrypt-to" ) #(...) #Line 387 pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $? However, for some reason, this is not working. So the question is, would it be possible to use this parameter to pass passphrase to gpg and use pass without prompt? If not, then are there any other ways to do so? EDIT: As @they suggested, here is info on what I'm doing: Set variable: export PASSWORD_STORE_GPG_OPTS="--pinentry-mode=loopback --passphrase '<password_goes_here>'" Remark: Password contains only small and big letters and digits - no whitespaces nor other characters. Then, execute the pass with: pass address/to/some/password Outcome is: gpg: decryption failed: No secret key
In my case, as @they suggested, problem was using (for unknown reason....) quotes. Without them, everything is working like a charm.
unix pass - passing passphrase with the usage of PASSWORD_STORE_GPG_OPTS
1,636,028,016,000
I am running Kali on a persistent USB (in a nvme enclosure) and it works fine. But when i do "passwd aUserName" log out and back in, the new password is used like it should. However when i reboot the the system the user needs to log in with the standard password again. Is there an explanation for this? I installed Kali on a 128Gb USB using "rufus.ie". After installation I tested it by booting from it. After that I made a clone of the USB and wrote that to my external SSD using "partitionwizard.com". The system is a variant of live Linux, when I boot I always choose "Live system (persistence, check kali.org/prst)"
Note that I have not used Rufus before and am not a Kali expert. However I have used very similar tools. It sounds like persistence is not working and to get it working you will need to reinstall. I can see persistence is mentioned in two different ways: Rufus has a persistence option Kali has a persistence option It's not immediately clear if these are expected to work together or if Kali's persistence is compatible with Rufus at all. The problem is that Rufus isn't just an imaging tool. It's unboxing the ISO image and building a system on a USB for you. Usually this involves packaging files into a read-only "casper" file. Typically Rufus Persistence would up a second partition partition and overlay this over the read-only file. Kali's ISO is already an image of a bootable live-linux; it doesn't need to be unboxed and assembled by Rufus. Kali themselves recommend just flashing it to your USB with Etcher. I suspect the persistence option offered by Kali either need's Rufus persistence to be enabled or is completely incompatible with Rufus. I can't easily tell you which. Your simplest option may be just to loop back around and use Etcher instead of Rufus. Alternatively you might want to just install directly onto your SSD. Boot from your USB flash drive, plug in your SSD and select "Install" on Kali's boot menu. Warning: There's a risk when doing this that the installer will corrupt your main OS (Windows?). If at all possible you should unplug your main hard drive before proceeding to ensure Kali's installer cannot access it and corrupt it.
kali user password not saved after reboot
1,636,028,016,000
I would like to read a password from stdin, suppress its output and encode it with base64, like so: read -s|openssl base64 -e What is the right command for that?
The read command sets bash variables, it doesn't output to stdout. e.g. put stdout into nothing1 file and stderr into nothing2 file and you will see nothing in these files (with or without -s arg) read 1>nothing1 2>nothing2 # you will see nothing in these files (with or without -s arg) # you will see the REPLY var has been set echo REPLY=$REPLY So you probably want to do something like: read -s pass && echo $pass |openssl base64 -e # Read user input into $pass bash variable. # If read command is successful then echo the $pass var and pass to openssl command. from man bash SHELL BUILTIN COMMANDS read command: read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, and the first word is assigned to the first name, the second word to the second name, and so on, with leftover words and their intervening separators assigned to the last name. -s Silent mode. If input is coming from a terminal, characters are not echoed. If no names are supplied, the line read is assigned to the variable REPLY.
Read from stdin and pipe to next command
1,636,028,016,000
We have a Linux system running Centos 7 and have an issue with the screen lock. We have a multi-user environment where each user has their own account. The authentication is using our university active directory. Only local accounts use the passwd & shadow files and indeed if a local account locks the screen they are able to unlock it. All other users are authenticated using the AD and get authentication error when they try. We are using sssd. This from secure log: Oct 30 08:59:54 b400 kcheckpass[94374]: pam_listfile(kscreensaver:auth): Refused user teach for service kscreensaver Oct 30 08:59:55 b400 kcheckpass[94374]: pam_sss(kscreensaver:auth): authentication failure; logname=syin uid=1005 euid=1005 tty=:0 ruser= rhost= user=teach Oct 30 08:59:55 b400 kcheckpass[94374]: pam_sss(kscreensaver:auth): received for user teach: 17 (Failure setting user credentials) Oct 30 09:00:02 b400 gdm-launch-environment]: pam_unix(gdm-launch-environment:session): session opened for user gdm by ouidad(uid=0) Oct 30 09:00:03 b400 polkitd[663]: Registered Authentication Agent for unix-session:c243 (system bus name :1.20066 [/usr/bin/gnome-shell], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) This from messages: Oct 30 08:59:55 b400 [sssd[krb5_child[94379]]]: Preauthentication failed Oct 30 08:59:55 b400 [sssd[krb5_child[94379]]]: Preauthentication failed Oct 30 08:59:55 b400 [sssd[krb5_child[94379]]]: Preauthentication failed Oct 30 08:59:55 b400 kcheckpass[94374]: Authentication failure for teach (invoked by uid 1005) The sssd logs were either empty or provided no clues. What can I do to make sure on login it checks against the AD instead of the passwd/shadow files for screen unlocks?
We figured it out ... the kscreensaver file located in /etc/pam.d was misconfigured during a recovery update. We had backup files of the kscreensaver configuration file and simply copied using cp command to the original condition before the update. #%PAM-1.0 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. # auth required pam_listfile.so file=/etc/allowed.nmr.users item=user sense=allow onerr=fail auth required pam_env.so auth sufficient pam_fprintd.so auth [default=1 success=ok] pam_localuser.so auth [success=done ignore=ignore default=die] pam_unix.so nullok try_first_pass auth requisite pam_succeed_if.so uid >= 1000 quiet_success auth sufficient pam_sss.so forward_pass auth required pam_deny.so account required pam_unix.so account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 1000 quiet account [default=bad success=ok user_unknown=ignore] pam_sss.so account required pam_permit.so password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok password sufficient pam_sss.so use_authtok password required pam_deny.so session optional pam_keyinit.so revoke session required pam_limits.so -session optional pam_systemd.so session optional pam_oddjob_mkhomedir.so umask=0077 session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid session required pam_unix.so session optional pam_sss.so systemctl rstart sssd We restarted sssd and the unlock function for active directory users was restored.
Screen Lock Checks password file but not Active Directory
1,636,028,016,000
What file/files is/are responsible for password aging in solaris server? Whenever a user is added, the default password aging limit is 90 days right? So is there a config file responsible for this?
For Solaris. grep MAXWEEKS /etc/defaults/passwd
File/files that is/are responsible for password aging in solaris
1,636,028,016,000
I have a CGI application that takes action as soon as it's loaded. Unfortunately, google's bots found it and they are ignoring the norobots, so the actions are being triggered at random times. So I want to password protect the CGI code. I don't want the cgi-bin script to handle the passwording - I want Apache to do it before the script runs. I can't see how to do this? Apache finds cgi-bin via a ScriptAlias. There's no Directory tag to set an AuthType on. Creating a directory for the script and handling it with <Directory> doesn't run it as a script. Is there a trick to this?
<Location> turns out to be the way. It's just like <Directory> but you specify a url path not a filesystem path, so /cgi-bin/particularScript is the thing to use. In my experience, norobots.txt gets ignored if Google finds your page via bookmarks in someone's Google account. It decides to crawl it regardless. I know that's how it found it because there are no public links to the page in question; it was a privately provided url and Google didn't visit it until after someone bookmarked it.
apache: password protect a cgi-bin app?
1,474,018,814,000
I'm currently migrating a CentOS environment to a Debian one. The users log in over the network using NIS. I was hoping to copy /etc/shadow from my old server to my new one so that we can offer continuity to the users. I discovered two problems with it: User ID conflicts This is easily resolvable by adding 500 to the UIDs in the CentOS shadow file since CentOS started UIDs at 500 while Debian starts them at 1000. Different password hashes This is what's killing me. It seems CentOS hashes its passwords with md5 while Debian uses sha-512. I would like to have the users be able to log in to the system without having to consult me. An acceptable solution I found after some Googling was as follows: passwd -d uname chage -d 0 uname The first line sets an empty password for the user uname so they can login directly. The second line causes uname's password to expire so that they're forced to change it on next login. I figure this is a good enough compromise. This is all well and good if the user logs in on the server. It does not work if the user attempts NIS authentication from a different box. They still get the message of "Password change required" but it's immediately followed by "Authentication Token Manipulation Error"; which, I'm guessing, is due to the fact that the password change is attempted via passwd rather than yppasswd. So this is the pickle I'm currently in. How can I achieve continuity without awkwardly forcing the users to first log in on the server? EDIT This is similar to what I'm talking about; except it makes no mention of NIS. This seems to suggest that it's actually impossible. Can anyone refute that or confirm it? EDIT 2 I just noticed that when users try logging in on the server, they can do so normally without error messages. On a different box (to test NIS), I switched to root then tried su'ing into one of the NIS users. It succeeds while giving me a warning that says "Authentication failed (Ignored)". I'm guessing this comes from the PAM policy chain.
It wasn't a matter of re-hashing passwords at all. All I needed was to modify my old /etc/group so that it has group IDs starting with 1000 and the users could log in easily using their old passwords as some commenters have guessed.
Rehashing /etc/shadow. Can I force NIS users to change password?
1,474,018,814,000
I have a USB stick encrypted with LUKS + Ext4. I have forgotten the password... However, I know which words will be included in the password and have a list of all permutations of those words. About 10,000 permutations. Instead of me trying each and every permutation 1 by 1 manually (which will be a long, slow, and painfully tedious process), is it possible to automate this process? I know this sounds like some sort of malicious brute force attack, but it's not. If I wanted something like that, I could have easily downloaded some dodgy software from the internet. Instead, I want to use something which is safe on my computer, a script (or any safe solution) which is custom built for me specifically. Is this possible?
Well, in the most naive case you can roughly do something like for a in 'fo' 'foo' 'fooo' do for b in 'ba' 'bar' 'baar' do for c in 'bz' 'baz' 'bazz' do echo -n "$a$b$c" | cryptsetup open /dev/luks luks \ && echo "'$a$b$c' is the winner!" \ && break 3 done done done and it goes through all the puzzle pieces ... foobarbz foobarbaz foobarbazz ... etc. in order. (If you have optional pieces, add '' empty string. If your pieces are in random order, well, think about it yourself). To optimize performance, you can: patch cryptsetup to keep reading passphrases from stdin (lukscrackplus on github for one such example but it's dated) generate the complete list of words, split it into separate files, and run multiple such loops (one per core, perhaps even across multiple machines) compile cryptsetup with a different/faster crypto backend (e.g. nettle instead of gcrypt), difference was huge last time I benchmarked it find a different implementation meant to bruteforce LUKS But it's probably pointless to optimize if you have either too little (can go through in a day w/o optimizing) or way too many possibilities (no amount of optimizing will be successful). At the same time, check: are you using the wrong keyboard layout? is the LUKS header intact? (with LUKS1 there is no way to know for sure, but if you hexdump -C it and there is no random data where it should be, no need to waste time then) There's also a similar question here: https://security.stackexchange.com/q/128539 But if you're really able to narrow it down by a lot, the naive approach works too.
Automate multiple password enties to decrypted LUKS + Ext4 USB stick
1,474,018,814,000
I want to change my root password everyday based on the date. The password will be like a combination of a string and the date. The below code is working fine. echo -e "pass"$(date +"%d%m%Y")"\n""pass"$(date +"%d%m%Y") | passwd root But how to call it each time the system starts and at mid night when the date changes (If the system is on.)?
I'm not sure why you would want to do that. If you're concerned about security, if someone discovers your password on 1 July, they'll know it on 31 July or 15 September... To answer your question, if you want to ensure that the password update is done either at a scheduled time or when the system restarts, you want to install anacron. It can do periodic scheduling without assuming the system is on all the time. I'm not sure what distribution you're using, but it should be in your package archives. Alternatively, you can use a mixture of traditional cron (changing the password at midnight) and an init script (to handle the case of rebooting) to ensure that the password is always up-to-date. In either case, put the commands to change the password into a script (say, /usr/local/sbin/rootpass.sh) and then call that script using cron or anacron and from your init script.
Dynamic change of Linux root password everyday
1,474,018,814,000
Can I change my phassword/-phrase('s settings) in a way that it's important which key of multpile ones (e. g. the left shift key instead of the right one) is chosen? Could I go a step further and ask for a specific order of keystrokes and their combinations even if the result isn't visible if typed the passphrase in a(ny) text program (e. g. deleting text during input)?
DopeGhoti's answer (No!) is the correct one, as long as we're talking standard software, which means reading the passphrase as a single line of text which you can type any way you want (and even correct typos), until you hit Enter. That said, it's technically possible to distinguish Left/Right shift keys, as xev easily demonstrates. So as long as the keyboard itself sends different keycodes depending on which key was pressed, you could work with it - if you go to the trouble of creating your own wrapper that reads individual keystrokes instead of text. Going further, you could even add things like having to enter the passphrase in a specific rhythm, or whatever. Kind of like cheatcodes some old games used to have. You could even use a real game controller to input those... So (Yes!) almost anything is possible, but you'd have to develop a program that provides such functionality, and make it turn your desired input into a textual representation or hash, which can then be used as the passphrase. And the problem then is to make it such that the user has a realistic chance of re-producing the same representation/hash repeatedly. So if you do decide to turn your passphrase input into a rhythm game, it should allow some generous leeway. With a regular keyboard pressing shift twice (without typing a letter) is no harm done, how would your software deal with such misinputs? In any case, with effort, it's possible. The bigger question then, is whether there is any point in doing this. Distinguishing left/right shift key only adds 1 bit of entropy anyway. It doesn't seem very useful. Passphrase wrappers in general are not unheard of, it's done to support dedicated hardware for example (like integrating a yubikey challenge response). 2-factor authentication, high entropy passphrase, may be worth it.
How to set the passphrase that different keys are discriminable
1,474,018,814,000
Is it possible to change strict requirements for user passwords, including root, e.g. I'd like not include numbers in the password as required, since this is a home machine, and I'm the only user?
On Solaris, password constraints can be configured by editing the /etc/default/password file , eg: $ pfedit /etc/default/password ... MINDIGIT=0 ...
Change requirements for passwords on Oracle Solaris 11.2
1,474,018,814,000
Is there a maximum password length on unix systems? If so, what is that limit and is it distribution dependent?
Depends on which particular crypt() algorithm one is using: modified DES: 8 ASCII characters MD5: Unlimited length Blowfish: 56 bytes NT Hash: Please don't use this one SHA256/512: Unlimited length More information: http://en.wikipedia.org/wiki/Crypt_%28C%29
Maximum password length
1,474,018,814,000
I have a script which executes curl many times. I'd like to enter my password only once (so I don't want curl to ask for it on every execution). I don't want the password to appear in process list or in a file descriptor or something. #!/bin/bash read -p "Enter pw:" -s pw provide_pw() { cat << END "$pw" END } for i in {1..10}; do curl -u $(logname):$(provide_pw) "$url" done Is this approach secure or is it possible for another user to get my password if I do it this way?
For all the dancing around with read and cat and heredocs, ultimately command substitution will result in $(provide_pw) being replaced by the actual password. It will then be part of the process details. From man curl, about -u: On systems where it works, curl will hide the given option argument from process listings. So, on such systems, and also on Linux systems with hidepid set appropriately, the password will be hidden from other users, but elsewhere, everybody can see the password by looking at the command line of the curl process using ps, top, etc. If you're willing to read the password, just have curl do it for you: If you simply specify the user name, curl will prompt for a password. Also see: How does curl protect a password from appearing in ps output? There is a race condition here: between curl starting and getting around to cleaning the command line, the password will be visible, and if it isn't hidden by other means (like hidepid on Linux), will be visible to everyone during that window.
How insecure is it passing a password to curl via cat
1,474,018,814,000
I got a bash script to synchronize data between two computers. It works fine but I have to type my password every time the rsync command is called. #!/bin/bash sourceIP="192.168.178.128" sourceUser="user1" destinationUser="user2" function sync() { rsync --archive --progress -v -e "ssh -l $sourceUser " $sourceIP:/home/$sourceUser/$1/ /home/$destinationUser/$1 } sync Pictures sync Music sync Videos sync Documents How to store the password (via prompt) in a variable and pass it to rsync/ssh?
What you really want to do is look at setting up public keys between the servers so they 'trust' each other and passwords are not needed. Have a read here: http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/
rsync over ssh without typing the password each time [duplicate]
1,474,018,814,000
I wrote a small bash script. It needs root password. There are two commands only, both of which need the permission. So, currently I must enter the superuser password twice - I don't want that. I linked the script to desktop. And I'm executing it from desktop I mean. My effort, which does not work: gksu -u root "iptables -D INPUT 7 && iptables -D INPUT 6"
You can run sh to combine two commands into one: sudo sh -c 'iptables -D INPUT 7 && iptables -D INPUT 6' Of course making a script will be more convenient if it's not a one-time thing.
First bash script - Enter root password only once
1,474,018,814,000
I need to set a password for root on EC2 AMI Linux. I have tried with passwd root but if I log in with ec2-user and run sudo su, I get a root bash without asking for a password.
sudo su asks for the user's password, the user has to be in the sudo/adm/admin/wheel group (depening on flavour of the OS) to be able to execute sudo. The root password will be prompted when using su alone. Check the settings in /etc/sudoers file to see why you are not being asked for a password while using sudo. Most likely the time-out is set to a few minutes, allowing you a passwordless sudo for e.g. 15 minutes after a successful password entry.
Set root password AMI linux
1,474,018,814,000
I came up across pdfcrack. I am trying to crack a file sent to me, but the password sent doesn't work. Now I do not know whether it is because it is version 1.5 or whatever the password doesn't work. I used the following link to understand how pdfcrack works. https://www.maketecheasier.com/recover-lost-pdf-passwords-linux/ Now while I could do a wordlist, first I tried using -n as shared in the manpage - -n, --minpw=INTEGER Skip trying passwords shorter than INTEGER As can be seen it says and IIUC, it means it will skip passwords lover than the number given - $ pdfcrack -f document.pdf -n=09 PDF version 1.5 Security Handler: Standard V: 2 R: 3 P: -1068 Length: 128 Encrypted Metadata: True FileID: 0 U= O= Average Speed: 48106.7 w/s. Current Word: 'qrbd' ^CCaught signal 2! Trying to save state... Successfully saved state to savedstate.sav! Now, as the file is sensitive in nature, I have removed the FileID as well as whatever hashes were generated by the file. Now the thing is, the current word or password it tries to hack is 'grbd' which is only 6 letters and not 9. IIUC, what I did above is have 9 letters instead of 6, what am I doing wrong?
The correct way to run this would be to skip the equal-sign, like this: pdfcrack -f document.pdf -n 9 But pdfcrack-0.20 is out now and should trickle its way to distros with time, so both might work soon. In the meantime, you can run it by skipping the equal-sign.
pdfcrack and minimum number of characters in password
1,474,018,814,000
I have 60 systems with different root passwords. Every 3 months I have to change their passwords. Currently I have to manually log into 60 systems and come up with 60 different passwords. Is there a smart way to do this? Can I use Ansible for this kind of job?
One way of doing this is to: Create a text file(*) containing the hostnames and the plaintext root passwords. Use whatever field separator you like - tabs are good. Ideally, you'd use a program like makepasswd or pwgen to generate passwords of sufficient length and complexity. IMO, 16 characters are the absolute minimum to consider using these days, and the longer the better. e.g. if you have a list of the hostnames (one per line) in hosts.txt, using something like the following: #!/bin/bash rm -f passwords.txt while read -r host ; do printf "%s\t%s\n" "$host" "$(pwgen -r \''`$' -y -c -n 32 1)" >> passwords.txt done < hosts.txt (this uses -r to prevent single-quotes, backticks, and $ from being used in the password, because dealing with them in the single-quoted-string-inside-double-quotes ssh command shown below would be a PITA). Example run: $ ./generate-passwords.sh $ cat passwords.txt host1 >?Mg^un=-Ipd8ZkY^TUC,_Gf/PAs%=9t host2 XS4?oZ@[+U\,(XeYOBcp{E^Q;!]2]ex< host3 SfupD}=a\J;}TJqqX.r}Kj;ab>Z|\=S2 You're going to need this list because otherwise you'll have no way of what the passwords are on the remote machines. ssh into each host and use chpasswd to set the password. To avoid having the password appear in plain text in the remote machine's process list, pre-encrypt the passwords on your local machine with openssl passwd and use chpasswd's -e option (this is only "safe" if you're the only user of your machine....and for quite limited definitions of the word "safe"). In this example, I'm using the -6 option for SHA-512 hashing. #!/bin/bash while IFS=$'\t' read -r host pass; do enc=$(printf "%s" "$pass" | openssl passwd -6 stdin) ssh "$host" "echo 'root:$enc' | chpasswd -e" done < passwords.txt This is really simple and primitive. There's no error checking. Or logging. But it does show the basic idea of how to use existing tools like pwgen, openssl, and chpasswd to automate password changes. I used to use scripts similar to these every semester at a university where I worked to generate passwords for new students in particular courses where shell access to specific machines (which were isolated from the main network) was required. The list was printed and cut into strips, and each user was given their password on showing their ID....this was far from perfect, but much better than having a default "password" that everyone knew. Obviously, most of the time you'll be logging in to the remote machines with an authorised ssh key and not using a password at all...but root passwords are still useful for logins at the console (or with a BMC or other remote-management facilities) in case of emergencies. (*) Because this passwords.txt file is plain text, you need to be very careful about permissions and who has access to it, but that's mostly outside of the scope of this Q&A. I suggest chmod 600 and encrypting the file with gpg - only decrypt it when you need to use it. I'd also suggest keeping the encrypted version in git or some other revision control system so that you don't lose your history of old passwords to try if the password update failed on some particular hosts for some reason (e.g. it was offline at the time) Or use pass to combine both gpg and git.
How to periodically change root password
1,474,018,814,000
I have a config file called .env which contains: DB_PASSWORD={password} Within /root/.mysql/db00.yml.db we have a password for the MySQL root account. I'm trying to pipe this into sed along the lines of: cat /root/.mysql/db00.yml.db | sed -i -e "s/DB_PASSWORD=/DB_PASSWORD=(.*)/g" .env Not having any luck, tried a few variations like: sed -i "s/DB_PASSWORD=/DB_PASSWORD=$(cat /root/.mysql/db00.yml.db)" .env mysqlpwd=$(cat /root/.mysql/db00.yml.db) # Use the variable in sed -i sed -i "s/DB_PASSWORD=/DB_PASSWORD=$mysqlpwd/g" .env This produces the error: root@linuxbox:/var/www/www.example.com# mysqlpwd=$(cat /root/.mysql/db00.yml.db) root@linuxbox:/var/www/www.example.com# sed -i "s/DB_PASSWORD=/DB_PASSWORD=$mysqlpwd/g" .env sed: -e expression #1, char 33: unknown option to `s' Update: Running it without /g also fails: root@linuxbox:/var/www/www.example.com# echo $mysqlpwd Rjcr/Sn+s/a2QbGx root@linuxbox:/var/www/www.example.com# cat .env | grep DB_PASSWORD DB_PASSWORD=(.*)() root@linuxbox:/var/www/www.example.com# sed -i "s/DB_PASSWORD=/DB_PASSWORD=$mysqlpwd/" .env sed: -e expression #1, char 33: unknown option to `s' None of these approaches seem to work. I am running sed 4.7, i.e.: root@linuxbox:/var/www/www.example.com# sed --version sed (GNU sed) 4.7
Try using a different delimiter for sed ... There are still risks of it failing depending on your actual password (e.g. if it included | or & or \1). sed -i "s|DB_PASSWORD=|DB_PASSWORD=$mysqlpwd|" .env
Passing a password (cat) to sed to replace config value
1,601,686,305,000
I tried pwgen and makepasswd to generate a password... but these are not enough to generate with exact count of literals and numbers... pwgen -c -n -y -B 12 1 This is not working as expected as I cannot define min numbers count... I want to define min and max chars allowed in each type of literals... does crunch have this feature? is there any other tool you suggest for this? shell scripts are most welcome... (with regex) Thanks in advance
Just run it until it works (in a newer version of bash that supports the =~ for regex matching): unset pass; until [[ \ $pass =~ [0-9].*[0-9] && $pass =~ [A-Z].*[A-Z] && $pass =~ [^A-Za-z0-9] \ ]]; do pass=$(LC_ALL=C pwgen -c -n -y -B 12 1) done For example: $ unset pass; until [[ $pass =~ [0-9].*[0-9] && $pass =~ [A-Z].*[A-Z] && $pass =~ [^A-Za-z0-9] ]]; do pass=$(LC_ALL=C pwgen -c -n -y -B 12 1); done; echo $pass AhP4eej3bie# Note that I am defining "symbol" as "not a letter and not a number". You can choose something more restrictive if you like. If your shell doesn't support regex matching, try: $ perl -le 'until ($pass =~ /\d.*\d/ && $pass =~ /[A-Z].*[A-Z]/ && $pass =~ /[^A-Za-z0-9]/){chomp($pass=`LC_ALL=C pwgen -c -n -y -B 12 1`)}; print "$pass"' iep7EJ-o9ahf
generate a password with minimum 2 numbers, 2 CAPS, 1 symbol, x lower alpha and max length of 16
1,601,686,305,000
I'd like to know if there's a way to customize the sudo password request. The default string is: [sudo] password for USER: Is there a way to change that to some other custom string, like: Insert sudo password: ? I want to clear this: I'm not asking how to change the password. I'm asking how to edit the terminal string that appears in the terminal when the system asks for the user password. Thank you! :)
You can do this like in the following example: sudo -p 'Insert sudo password: ' echo "Hello World!"
Customize password request string
1,601,686,305,000
I was wondering if there would be any issue with placing a single quote in a ubuntu user's password. We have a couple machines with a dummy user for automation purposes and I would like the password to be the same across all platforms (not the best for security I'm aware). Would a single quote be treated as a string literal even when setting a password or is setting a password treated as input for dev/tty and not stdin in this case so the escaping wouldn't occur?
there should be no problem in interactive mode (on the tty). If you want to set it by script, you may need to escape it, or use other quote (e.g "Pass'word" or 'Pass"word' ).
Can I put a single quote in a user's password
1,601,686,305,000
I use Ubuntu 16.04 with Bash and I tried to run the following command set to automatically create a WordPress wp-config.php file with the WordPress Bash extension WP-CLI. Yet I'm having some problem I miss (Bash related?). loh="127.0.0.1" drt="/var/www/html" domain="example-xyz.com" dbuserp_1="example-xyz.password" rm -rf "$drt/$domain"/ 2>/dev/null wp core download --path="$drt/$domain" --allow-root wpConfig() { rm -rf "$drt/$domain"/ 2>/dev/null wp core download --path="$drt/$domain" --allow-root wp config create \ --path=${drt}/${domain} \ --dbname=${domain} \ --dbuser=${domain} \ --dbpass=${dbuserp_1} \ --dbhost=${loh} \ --allow-root } wpConfig I double checked that the DB user password I use is correct. And yet, I get this error: ERROR 1045 (28000): Access denied for user 'example-xyz.com'@'localhost' (using password: YES) Changing all ${x} to "$x" changed nothing. I fail to understand why I get the above error (what does it have to do with MySQL itself, as this error seem MySQL related).
If your MySQL database and/or user aren’t created before you run wp config create, you need to tell it to skip the database check: wp config create --skip-check ... This will create wp-config.php with the parameters you specify, and it won’t fail if it can’t connect to the database.
Automating wp-config.php creation
1,601,686,305,000
I use Volumio, built on Debian. I want to change the password for the default volumio user, so I type: volumio@volumio:~$ sudo passwd [sudo] password for volumio: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully volumio@volumio:~$ reboot When the device restarts, the new password doesn't work but the old one does. What have I done wrong?
You are resetting root's password when using sudo passwd. The command literally means 'run passwd as root'. To change the user's password, you simply use passwd. This command is meant to be used by standard users. This works because the command file is assigned the 'suid' bit.
Debian password change discarded
1,601,686,305,000
I would like to automate a script that regularly runs rsync, and rsync prompts for my ssh key password each time I run it. I don't mind typing the password once at the beginning of the script. I can't be prompted each time it runs an rsync command in a loop. Is there a clean, safe way to prompt for the password once and continue using it? My assumed solution would be to prompt for the password somehow (not sure how to do that off the top of my head) and store it in an environment variable, then use expect to make use of it. But I feel like there might be an easier approach that I'm not aware of.
Set up an authentication agent. Namely ssh-agent. This runs in the background and intercepts requests that require authentication. When you start the agent it will ask you for your passphrase one time. It keeps it in memory and each time authentication is required (e.g. using SSH you log into a remote host on which your key has been installed) it automatically inserts it. Here's one way to get up and running. Create a script and put it somewhere convenient (e.g. ~/bin) like so: start_agent () { echo "Initialising new SSH agent..."; /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}; echo succeeded; chmod 600 "${SSH_ENV}"; . "${SSH_ENV}" > /dev/null; /usr/bin/ssh-add } # Source SSH settings, if applicable SSH_ENV=$HOME/.ssh/environment if [ -f ${SSH_ENV} ]; then . "${SSH_ENV}" > /dev/null # ps flags are not always portable so check here if agent doesn't start ps -p "${SSH_AGENT_PID}" || start_agent; else start_agent; fi Then simply source this script: . ~/bin/ssh-agent-init.sh. You will be prompted for your passphrase at this point so enter it and then you're good to go. You can source it from your .bashrc if you want it to run all the time.
How to automate a script that requires an ssh-key password at regular intervals [duplicate]
1,601,686,305,000
I can use RSA keys to putty into my centos VPS with no problem. And from there I can use sudo to run commands. But my root password is not working. I wonder if I hosed something while setting up passwordless putty logon. When I do su whatever neither of my past couple of root passwords work. Using sudo I changed sshd_config to permit: PermitRootLogin yes PasswordAuthentication yes Then reloaded the sshd service. But couldn't then ssh in as root either. Suggestions? Update 1 Tried sudo su but the result was This account is currently not available. But my user password works with sudo nano /etc/ssh/sshd_config. And I successfully edit that file.
Sounds like you don't know your root password, if even su refuses your password. Hence, what you should do is reset your root password. Having sudo su, run passwd, type in your new passphrase twice when prompted, ... Now you don't necessarily need to know of your root password. If you're already using some RSA key logging into your VPS, you should be able to authorize that key connecting as root. And even though: you don't necessarily need to log in as root. If you can sudo from a management user, why would you want your root account to be authorized logging into your SSH server? Assuming you just want to login using SSH keys, change your sshd_config: PermitRootLogin without-password PasswordAuthentication no Assuming you prefer to prevent root from using SSH, just go with: PermitRootLogin no PasswordAuthentication no If and only if, you're sure you want root password authentication to be allowed over SSH, knowing of your su password, you may consider going with: PermitRootLogin yes PasswordAuthentication yes If you want to make sure root password authentication is disabled system-wide, you could run (as root): passwd -d As of your last edit, in regards to sudo su failing with This account is currently not available.: this would indicate your root account shell was changed to something like nologin. Try this: sudo su -s /bin/bash. Assuming it did open a root shell, you may then want to change your root shell using chsh.
root password not working but can ssh via sudo user (centos)
1,601,686,305,000
How can I generate a dictionary of words containing 8-16 of alphabet characters ([a-zA-Z]) with low memory?
You asked how to create one, but just in case you want one: https://forums.hak5.org/index.php?/topic/29308-13gb-44gb-compressed-wpa-wpa2-word-list-982963904-words/ As for creating one, consider checking out a program called crunch (wordlist generator).
Wordlist/dictionary generation for penetration testing
1,601,686,305,000
gksu doesn't has an option like sudo has to pass the password to it in the following way: echo 'password' | sudo -S command Anyway I wonder which is the simplest way to pass my password to gksu. What I found until now is: parallel -j 2 -- "gksu command" "( sleep 1; xdotool type 'password'; xdotool key 'Return' )" But this doesn't look so good for me (parallel and xdotool must to be installed, there is some time spent until the password is passed, the window which asking password is not avoided). So, is there a better way? Note: I'm not interested to edit the sudoers file or in explanations like "don't do this, it's not safety!".
Both gksu and gksudo pass your password to sudo. Try running them in a terminal with the --debug option: gksu --debug gedit You'll notice that they run sudo with the -H option (as well as -u and -p for username/password and -S option to avoid a terminal). Therefore, you really just need to use sudo -H instead of gksu or gksudo.
How do I pass my password to gksu?
1,601,686,305,000
I have a zsh script with which I logged into a remote host to copy some folders. The system asks me each time to give the password of the local host which I want to bypass, otherwise I have to enter the passphrase many times. I followed the following tutorial: https://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/ It worked once but then it didn't work. I followed the following steps (and followed them many times again) but now it does not work anymore. [local-host]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):<Hit enter> Enter passphrase (empty for no passphrase): <Enter your passphrase here> Enter same passphrase again:<Enter your passphrase again> Your identification has been saved in /home/jsmith/.ssh/id_rsa. Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub. The key fingerprint is: 31:3a:5d:dc:bc:81:81:71:be:31:2b:11:b8:e8:39:a0 jsmith@local-host I then copied the content of the public key from the local-host and pasted it to /home/jsmith/.ssh/authorized_keys on the remote-host and ran: [remote-host]$ chmod 755 ~/.ssh [remote-host]$ chmod 644 ~/.ssh/authorized_keys But then if I tried to log again, [local-host]$ ssh jsmith remote-host But instead of having the following message: Enter passphrase for key '/home/jsmith/.ssh/id_rsa': <Enter your passphrase here> Last login: Sat Jun 07 2008 23:03:04 -0700 from 192.168.1.102 No mail. I get this: jsmith remote-host's password: What am I doing wrong? EDIT Many thanks for the answer and the comments which I'll try to adress point per point: regarding the -l, I indeed did not use but instead I used ssh jsmith@remote-host I run the following with the following output [local-host]$ eval $(ssh-agent -s) Agent pid 96546 [local-host]$ env | grep SSH SSH_AUTH_SOCK=/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T//ssh-9ew9mjQCJWFK/agent.96545 SSH_AGENT_PID=96546 EDIT 2 So then I tried the following [local-host]$ ssh-add .ssh/id_rsa Enter passphrase for .ssh/id_rsa: Bad passphrase, try again for .ssh/id_rsa: EDIT3 Ok so the whole permission tree on the remote machine and local machine is the following: /var/services/homes/user01/.ssh/ the permissions of each branch are the following (with ls -ld <directory> and ls -la <file> command (from bottom up): For the remote machine: drwxr-xr-x 1 user01 users 0 Oct 3 16:44 .ssh drwxrwxrwx+ 1 user01 users 90 Oct lrwxrwxrwx 1 root root 14 Oct 4 09:07 homes -> /volume1/homes drwxr-xr-x 2 root root 4096 Oct 4 09:07 services drwxr-xr-x 15 root root 4096 Oct 4 09:07 var For the local machine: drwx------ 7 user02 staff 224B Oct 4 09:27 .ssh/ drwxr-xr-x+ 152 user02 staff 4.8K Oct 4 09:27 user02/ drwxr-xr-x 6 root admin 192B Jan 1 2020 /Users/ Do you have an idea about what I should do next? Many thanks in advance
You need to run the local ssh-agent. And in the "I tried to log again" you forgot the -l (or, alternatively, jsmith@remote-host). There's a good chance that you did start the agent and did the ssh-add part, too, but in a different session. What I do is to invoke eval $(ssh-agent -s) from my window-managers initialisation, that way any shell will know about the agent ... $ env | grep SSH SSH_AUTH_SOCK=/tmp/ssh-LxwUgd8tuGU3/agent.1023801 SSH_AGENT_PID=1023802 On top of everything else, a chmod 750 $HOME and chmod 700 $HOME\.ssh are important too, though the initially described messages didn't hint at those.
Log in to remote server by using a generated public key
1,601,686,305,000
I'm on a Raspberry Pi, but I don't think this question is specific to Raspberry Pi OS. I only use an SSH key to log in as user pi. I have a script that calls sudo -v which currently asks for the password for user pi. I want to make this step easy, so preferably have it not ask for a password at all or have a very simple password (like "pi"). But of course I don't want to expose a user account via SSH with such a simple password. I already have a file in /etc/sudoers.d that contains pi ALL=(ALL) NOPASSWD: ALL but it doesn't disable the password question for sudo -v. What are my options? Edit: Output of sudo -l as requested in the comments: pi@klipper:~ $ sudo -l Matching Defaults entries for pi on klipper: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, env_keep+=NO_AT_BRIDGE, env_keep+="http_proxy HTTP_PROXY", env_keep+="https_proxy HTTPS_PROXY", env_keep+="ftp_proxy FTP_PROXY", env_keep+=RSYNC_PROXY, env_keep+="no_proxy NO_PROXY" User pi may run the following commands on klipper: (ALL : ALL) ALL (ALL) NOPASSWD: ALL
Remove (or better, comment out) the first of the two lifted authorisation lines in sudoers that applies to pi: (ALL : ALL) ALL (ALL) NOPASSWD: ALL This unwanted one does not have the NOPASSWD flag so you will be prompted for a password. (First matching rule applies.) Generally speaking, I would advise you open two shells. Use sudo -s in the first to get a root shell and do not close this until you have confirmed that your edits haven't locked you out from using sudo. Use the second for your testing. Always use visudo to edit the sudoers files. I should point out that if the first line corresponds to the group definition %sudo ALL=(ALL:ALL) ALL you should not comment that out without good reason as it allows anyone who is a member of the sudo group to use the sudo command. Either modify it so that all members of this group need not provide their password, or else put your own user line above it so that it matches first: pi ALL=(ALL:ALL) NOPASSWD: ALL
Disable password login but keep sudo -v?
1,601,686,305,000
In Linux about compression files can be accomplished with the tar and zip/unzip commands, perhaps more. I know that is possible establish a password protection for security reasons. The question is: Is possible compress and uncompress a file with a password but considering a expiration date too? For example: Is created some information in the omicron directory It is compressed with the abc password and it expires in an specific date - established manually for example using the --pwd-expire-date 05/05/2023 option (of course, if it is possible) Situation The compressed file is shared to Person1 and Person2 - now, even if Person3 gets the file for any reason - if he gets/breaks the password but it happens at 05/06/2023 (one day later), it can't be uncompressed due the expiration date. Is possible accomplish this goal?
You cannot encrypt files using tar, use tar+gpg if you want to do so. You can encrypt files using zip, but it won't keep track of file attributes (such as ownership, permissions, etc.), depending on what you want to compress, zip might no be suitable. You cannot set an expiration date on something you encrypt, you have the key to decrypt it or not, there's no such thing as "this secret key is not valid anymore". Encryption is a "static" process, you cannot control access to the cipher if the other party has the key to decrypt it. Certificates do have expiration dates, but that's for signature verification purposes only, not encryption. Plus, it is up to the client to consider that expiration or not. What you could do as a workaround is to upload an encrypted archive somewhere (like swisstransfer), and set an expiration date at which it won't be possible anymore to download the file
Is possible compress and uncompress a file with a password but considering an expiration date too?
1,601,686,305,000
I had created two users on Linux with the same exact passwords, but when I looked at the /etc/shadow file, I found that the hashed values look different, although the salt file is the same. (Please see below, j9T is the salt). Why the hashed passwords are NOT similar, although the slat and password are similar? # tail /etc/shadow Bob:$y$**j9T**$ewJ0HB756BZDnPjx7zzbm0$i39AKrfuQuvvoQJpujwWd7Z4bcZgN1l0IWeJsNmLzg7:19254:0:99999:7::: Bob:$y$**j9T**$pFF5c93UZvdFYD2nanxEO.$SMhaxtPUPEUZdZZx.b1tGmjXgM67nqBJgMk2sNP.5s4:19254:0:99999:7:::
The second field (j9T) is not the salt, it's the param (hash complexity parameter). You could read more information about the format of the hash here and here You salt is actually the third field, and you can see it's different. The actual hash is the fourth field.
Hashed passwords are NOT similar although the salt and password are similar
1,601,686,305,000
I want to check whether the passphrase of my user-id located inside a file is correct or not. I have stored my passphrase in a file (/home/user/.gpg_pass.txt), than I use it as: gpg --verbose --batch --yes --pinentry-mode loopback \ --passphrase-file=/home/user/.gpg_pass.txt --decrypt <file> Before using this command, I want to verify that the passphrase inside the file is correctly entered. I have tried, which did not help: cat /home/user/.gpg_pass.txt | gpg --dry-run --passwd <key_id> From man of gpg: --passwd user-id Change the passphrase of the secret key belonging to the certificate specified as user-id. This is a shortcut for the sub-command passwd of the edit key menu. When using together with the option --dry-run this will not actually change the passphrase but check that the current passphrase is correct. When I enter: $ gpg --dry-run --passwd <key_id> Two times following window show up I enter the passphrase, (if wrong passphrase is entered it says Bad Passphrase (try 2 of 3) in the GUI-console): ┌────────────────────────────────────────────────────────────────┐ │ Please enter the passphrase to unlock the OpenPGP secret key: │ │ "Alper <[email protected]>" │ │ 3072-bit RSA key, ID 86B9E988681A51D1, │ │ created 2021-12-15. │ │ │ │ │ │ Passphrase: __________________________________________________ │ │ │ │ <OK> <Cancel> │ └────────────────────────────────────────────────────────────────┘ Instead of manually entering passphrase into GUI inside console, can it be pipe in the gpg --dry-run --passwd <key_id> and can its output could be returned, verifying is the given passphrase correct or not? Related: https://stackoverflow.com/q/11381123/2402577
Try gpg --batch --pinentry-mode loopback --passphrase-file=/home/user/.gpg_pass.txt --dry-run --passwd your-keyid as the man page also says that these are the options to allow to get the password from a file. Note that if you want to do that from inside a script, I'd assume it sets the return code depending on the outcome, so check the return code ($? in most shells, use echo $? if you want to check manually).
How can I check passphrase of gpg from a file?
1,601,686,305,000
I am very new to Linux and I'm not super computer savvy so that's sort of why I don't really know what I'm doing. I try to reset my root password in a Chromebook. As far as I know, I need to boot to the GRUB menu but I cannot figure out how to do that. I'll try to answer whatever questions I need to but just remember I'm sort of new to all of this. What I have tried so far is rebooting my Chromebook (holding the refresh button+the power button), and holding Shift, which as far as I know is supposed to open up the GRUB menu. It didn't really even reboot, I believe it just shut down, so I guess the reboot itself didn't work, and in that case, I'm not sure how to do that either since there doesn't seem to be an option for it (if what I did already didn't work).
i've using Linux for 2 years. I have never used Chromebook. I believe you know how to use terminal. So fire up a terminal and type the following If you know your root password, login into root.To do that Execute the following su This will prompt something like this Enter password Enter password, now you will be a root user. Then execute passwd This will prompt you to enter a new password. If you forgot the root password, just type sudo passwd This will ask you for your user password. Enter it, now you will be prompted to enter a new password, this will change your root password. Lemme know if it worked. Good day !
How do I reset my root password on Chromebook?
1,601,686,305,000
On the gdm login screen and on the GNOME lockscreen in the password entry box there is this little password reveal button at the right side. Since this is a toggle some classmates were able to trick me into showing a good portion of my password by just pressing this button while I was away and watching me typing my password in. Now is there any way to remove this button or show the password only while it is pressed? I've found really NOTHING on this topic on the internet except this askubuntu article asking for exactly the opposite what I want.
Just set the dconf property disable-show-password in /org/gnome/desktop/lockdown to true for the gdm and your own user. gsettings set org.gnome.desktop.lockdown disable-show-password true Side note: I've stumbled across this prior to asking this question but a bug in GNOME 40 prevented this setting from being recognized. The bug is now resolved and this solution works perfectly well for me now.
GNOME/gdm disable reveal password button
1,601,686,305,000
I wish to non-interactively provide the password which is prompted when I start apache httpd webserver. The password would be a variable. I don't want the prompt and feeding password manually like below: /web/apps/perf/apache/2.4.46/https-model/bin/apachectl -k start Apache/2.4.46 mod_ssl (Pass Phrase Dialog) Some of your private key files are encrypted for security reasons. In order to read them you have to provide the pass phrases. Private key model.com:443:0 (/web/apps/perf/apache/2.4.46/https-model/ssl/model.key) Enter pass phrase: I tried the below option but none of them help. echo -n "mypassword" | /web/apps/perf/apache/2.4.46/https-model/bin/apachectl -k start echo "mypassword" >> /web/apps/perf/apache/2.4.46/https-model/bin/apachectl -k start /web/apps/perf/apache/2.4.46/https-model/bin/apachectl -k start << echo "mypassword" /web/apps/perf/apache/2.4.46/https-model/bin/apachectl -k start << cat mypasswordfile (where mypasswordfile is a file having the password.) Can you please suggest?
It looks like your private key for the SSL certificate is password protected. Usually, the best and easiest approach is to remove the passphrase from the key. openssl rsa -in [original.key] -out [new.key] You'll be prompted for your key's password. After running, new.key would be without the password. You can either replace it or point Apache to the "newly" generated key. If for some reason you'd like to have a passphrase for your private key, you can use this approach - https://serverfault.com/a/160835
Start apache HTTPD webserver non-interactively
1,601,686,305,000
I recently set up ssh on my linux mint server. I wanted to change the password on it because of security reasons. I followed this guide to change the password. The password was successfully changed, and I know because if I want to change it again the 'old password' is the one I changed it to. However, when I try to login, the new password is denied, and the old password is accepted. Any help appreciated!
There are two authentication methods at play here: password-based and key-based. The guide you have linked to provides instructions to change the passphrase, which only affects key-based auth. As noted in the guide, a passphrase is used to add another layer of protection to an SSH private key. When you change a passphrase, the change occurs on the client side. If the server does password-based auth, you would see no difference. Passwords are authenticated on the server side, against a user directory of some kind. This can be the default /etc/shadow file, or something more complex such as an LDAP server. ssh -vvv will help diagnose this. The debugging output will show the list of authentication methods that the server accepts, and which one is currently being used.
Changing SSH passwords doesn't do anything