date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,601,686,305,000
I have the following users with password from /etc/shadow: userA:$5$FSRFdXhqehxiiFZV$SoIvO/4Y2tvOzIi.8p1Ud6AInQ3K5XT/WqVE5Zh4GT8:18388:0:99999:7::: userB:*:18388:0:99999:7::: userC:$6$SJRweUUklycIq1C$ZKCPyeM9bAoTynYioSYBOmZTATXsajucfHNE3ZNfWNmql1GKdsYCTprf/aXOspBxxzlRuDEvjRlzLf7rbx.fy0:18388:0:99999:7::: userD:$6$YgVQv3fSdlYwR$yOn6MBS5dGhMoFmPri4tsLYFzFgd0.nc8VYrSBykn/4qQwGV31NhMtoV/VJfhNqkA.FH0oP7GKxqYyK/4/0nr.:18388:0:99999:7::: userE:$1$8HptDKnp$w32YYwwlxi9F.2JDO/gSA.:18388:0:99999:7::: userF:$6$DWKlq62oU9k8O/z$aMNpueRgSIcILIpSMNV.gnSven6kgNbJ4QJlQM1E32snjhndk3LvfWtnR4NoiFIE4NwC7Kga7PZTlWDaxD0Gd1:18388:0:99999:7::: userG:X014elvznJq7E:18388:0:99999:7::: userH:$6$yhVabCDsrFv$CImM3mQGwX6Scbi/mGsl/jwKFJcdnsEq/Wjlve6ApB21ytw6/.weDMi6QkjJh3RiCO9xTBatNjwxd7vUddRS2/:18388:0:99999:7::: Furthermore, I know someone useses the "EasyDiamond" as password. I want to find out who uses it. I tried to use online hashing tools to get the output hash, but unfortunately didn't get a single match. E.g. for userA tried hash the EasyDiamondFSRFdXhqehxiiFZV with SHA-256 and so on. What am I doing wrong?
The password hashing schemes $5$ and $6$ are not just single SHA256 or SHA512 hashes of the password + salt. That would be way too easy to brute-force. Instead, the hashing is iterated a configurable number of times: if the password hash does not include a $rounds=N$ specifier, the default is 5000 iterations. You'll find a complete description of the algorithm at: https://www.akkadia.org/drepper/SHA-crypt.txt OpenSSL includes a tool that can be used to calculate password hashes. For example, to manually check the password EasyDiamond for your userA, you would run: openssl passwd -5 -salt FSRFdXhqehxiiFZV EasyDiamond The output will be the result of the chosen password hashing algorithm (option -5 specifies the $5$ algorithm) with the specified salt (from the /etc/shadow line) and password. If it matches what is listed for userAin your /etc/shadow, you now know userA's password is EasyDiamond. The man page for openssl passwd may be a bit tricky to access, since OpenSSL usually has a separate man page for each subcommand, and this subcommand is named passwd which matches the regular passwd command. Different distributions may solve this in different ways, but a common way is to use a man section name with a suffix: in Debian/Ubuntu family of Linux distributions at least, man 1ssl passwd will produce a man page for the openssl passwd subcommand. Or you might use man -a passwd to get all the possible man pages for passwd, including at least /usr/bin/passwd, openssl passwd and /etc/passwd.
Define the user with the specific password
1,601,686,305,000
This is what I'm working with: pwgen 15 1 -cny I need to include at least one uppercase letter, one number and one symbol. What I need to change is to make it include one of these symbols: "! @ # $ % ^ * - _ + = & ~" How do I do that?
You can use -r to specify list of characters to not be included in the password, so if you want only specific list of symbols to be used, you can use list of symbols pwgen uses, remove yours from the list and use it for -r. pwgen 15 1 -cny -r "\"\'(),./:;<>?[\\]\`{|}" T+aPpfP61Y6yZs! Unfortunately this will stop working if pwgen ever decides to change the list of symbols but I don't see other way to do it with pwgen only.
Help with pwgen syntax
1,601,686,305,000
On my Ubuntu 18.04 system, there's a user called myuser without a password: tester@box:~$ passwd -S myuser myuser NP 03/31/2020 0 99999 7 -1 When I log in to the machine locally and switch to myuser via su myuser everything works as expected, no password prompt, I'm directly switched to the specified user. However, when I log in to the same machine via SSH, and then run su myuser, I get prompted for a password. Edit: Same user used for logging in locally and via SSH. Where does this difference in behavior come from? There must be a explanation, currently I'm a bit lost.
You can replace nullok_secure with nullok in /etc/pam.d/common-auth. You may also need to adjust values in /etc/pam.d/sshd if you have some specific overrides. You should have something like this in your common-auth file: auth [success=1 default=ignore] pam_unix.so nullok
'su user' behavior differs when logged in locally vs via ssh
1,601,686,305,000
According to the manual of argon2 (Debian package), it says to pass the password from standard input. However, when I follow the instructions and attempt echo -n "password" | argon2 salt "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"-t 4 -e the program simply returns Error: unknown argument. What am I missing here? The manual says The supplied salt (the first argument to the command) must be at least 8 octets in length, and the password is supplied on standard input.
The first argument, the salt value, should be the actual salt that you want to use. Therefore, your command should probably look like echo -n "password" | argon2 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -t 4 -e if the string of a characters is your salt. Note also the space between the salt string and the -t option. This literal command would output $argon2i$v=19$m=4096,t=4,p=1$YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ$9rVLOMSIM9ehkD8zj0aK62CZhchXpDxV/gKcBUQCnbQ
Unable to pass argument to argon2 command
1,601,686,305,000
I’ve encrypted one file with des algorithm using openssl tool but I forgot my key . Is there any way to recover that key or get any hint or something?
Sure, a brute force attack trying every single combination of passwords should work...eventually. How much time do you have? I presume you want to do this quickly, in which case the answer is almost certainly No there is no 'practical' way using the program and ciphertext/output.
Openssl forgot password
1,601,686,305,000
I have a server where MAXWEEKS is set to 13 in etc/default/passwd. I know that this setting means that password will expire after 13 weeks. My question is if the user does NOT change the password, does the account become locked out after this or does the system will force the user to change the password when the user logon? What setting can be set to automatically revoke access after certain weeks on inactivity?
The MAXWEEKS only sets the amount of time a certain password may be used before the user if forced to change it. The user will get a prompt with a request to change the password before the user can further login to the system. Locking of an account after a period of inactivity requires a more advanced authorization management tool. NIS+ might be something on Solaris that can do this for you.
MAXWEEKS on Solaris is equals to 13
1,601,686,305,000
I used console command passwd to change my own password that I set straight after the OS installation with useradd command. My original password contained only line characters, without capitalization, numbers or special characters, but passwd prohibits me to set similar (only line characters) password. Why useradd was less strict than passwd? Is there any way to set "simple" password for already existing user? P.S. I understand that such requirements are often suggested for security reasons, but this my own laptop and my own system.
The password subsystem is configured to enforce a "non-weak" password policy of some sort. The root user - which is the user you were operating as when you created the account and set the initial password - isn't limited by this policy. Assuming your user is set up and authorized to use the sudo command, you can set your password to be a weak one via sudo passwd yourusername If you set the root user's password and know it, you could also do su -c "passwd yourusername" And enter the root password when prompted.
Why passwd prohibits me from setting "simple" password?
1,601,686,305,000
When my script starts, the shell asks me for the password for the module apt-get, and then again for ansible, because it has the option --ask-get-pass. How do I enter the password only once for this script? sudo apt-add-repository -y ppa:ansible/ansible && sudo apt-get update && sudo apt-get install -y ansible && ansible-playbook --ask-become-pass playbook.yml
The read command works in my case: read -s -p "SUDO Password: " pass echo "$pass" | sudo -S apt-add-repository -y ppa:ansible/ansible && sudo apt-get update && sudo apt-get install -y ansible && ansible-playbook --extra-vars "ansible_become_pass=$pass" playbook.yml @Cometsong thanks for clue
How to save the password for the next commands in the shell script?
1,601,686,305,000
I am root in a system. There seems to be a passwordless user in this system I try becoming a different specific user by using "su - username", and get a "Password" prompt. No matter if I enter a password, or not enter a password and just press enter, I still become that user. Why is this?
Normally root doesn't get a password prompt at all. Linux's su doesn't support passwordless accounts; login allows any password if the account is passwordless. The behavior you describe sounds like a bad PAM configuration, perhaps lines in the wrong order. Check your PAM configuration: /etc/pam.conf, /etc/pam.d/su and any included file. The important lines are the auth lines. A typical basic configuration for su is auth sufficient pam_rootok.so auth required pam_unix.so I don't know what the default setup is on CentOS, it might be more complex to allow LDAP authentication, Kerberos, home directory automount, etc. If you need help understanding it, post your PAM configuration (at least every auth line that applies to su, in the right order).
Passwordless User
1,453,903,263,000
Given the relative (anyone with my present user permissions can swipe scancodes) ease of keylogging in an x11 environment, should I run GPG tools only in the TTY?
I'm not sure what you mean by "swipe scancodes", but I would say No. Do not use GPG tools with sensitive private keys when you are not confident that the system integrity is up to par. Perhaps I'm too sensitive/paranoid, but if keylogging the X environment is a concern, why wouldn't the TTY also have integrity concerns? Maybe we don't have enough info. Are you running a remote X session over the network?
Is it safe to run GPG tools in x11?
1,453,903,263,000
Can I, and in that case how can I, change the password of an SSH identity file without having to generate a new key and setting up it all over again?
Identity file = private key file? From the manual, (man ssh-keygen): ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile] The -p switch changes the passphrase of a private key file with a prompt, whereas the -P switch specifies the old password on the command line. Use one of these in interactive mode depending on the encryption algorithm and file name you have used. ssh-keygen -p -f ~/.ssh/id_dsa ssh-keygen -p -f ~/.ssh/id_rsa
How to change password of an ssh identity file
1,453,903,263,000
I'm going to build an experimental mail server with Postfix + Dovecot and Mysql for user accounts. The server will offer SMTP + POP3 + IMAP. Is there a way to force users to change their mail account passwords every six months?
grep'ing through dovecot 2.1 source code it appears that they have a constant IMAP_RESP_CODE_EXPIRED used for the RFC 5530 "EXPIRED" code, which would be used to tell the client the password has expired. I see code to that notices expired accounts, and returns PASSDB_RESULT_PASS_EXPIRED from various different methods (but not the db-sql method). Further, I don't see anywhere where the server sends that response. This holds true in 2.2 as well, where a few more authentication methods gain PASSDB_RESULT_PASS_EXPIRED (but still not db-sql). And still nowhere I see the server sending it. So, I'd guess that Dovecot currently doesn't support this, but they're (slowly?) working towards it. I'm not even sure the IMAP protocol provides a way to change a password. I couldn't come up with one despite serious Google attempts. (You could email people warning them their password is about to expire, and set up a web page for them to change it, but, well, I bet I have several of those in my spam box right now! Oddly enough, not actually sent by mail server's admin. In case the sarcasm doesn't carry, this is a relatively common phishing scheme.)
Force users to change email password every six months
1,453,903,263,000
Source: https://linuxopsys.com/topics/chage-command-in-linux The image is taken from the book Linux with Operating System Concepts. What I don't understand here is that what is -E option? Is it the date when password expires or account becomes inactive? What's the difference between account expiry and account becoming inactive? From the man pages: -E, --expiredate EXPIRE_DATE Set the date or number of days since January 1, 1970 on which the user's account will no longer be accessible. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area). A user whose account is locked must contact the system administrator before being able to use the system again. -I, --inactive INACTIVE Set the number of days of inactivity after a password has expired before the account is locked. The INACTIVE option is the number of days of inactivity. A user whose account is locked must contact the system administrator before being able to use the system again. The confusion exists between -E and -I option.
Maybe the confusion is due to two different things that might expire: the account, and its password. Consider the following sequence of events: The account is created at time T0. It is set to expire at time Te using the -E option. A password is set on the account. The password is set to expire at time Tp using the -M option. The account is set to lock at some time dT after the password expires using the -I option. Then: Te is unrelated to and independent of Tp and dT. The account can get locked at the earlier of Te (locked due account expiration) and Tm = Tp + dT (locked due to inactivity after password expiration). Now, inactive can mean multiple things. It can mean that there is no activity on the account, so no one has logged into it. It can mean that the account is no longer available, so no one can log into it. Which meaning is used depends on the context. During the time between Tp and Tm, the account is inactive - no one has logged into it. After Tm or Te, the account is also inactive, but because no one can log into it.
What's the difference between account expiry(inactive) and account becoming locked?
1,453,903,263,000
According to Securing section in FreeBSD Manual, the $2a$ corresponds to blowfish. But In my FreeBSD box I have $2b$. xan:$2b$04$F1SclFRRh8c8N6ICwdAb.ud5lfTKhRyL1PuRxvUDsQINlsK8YG9Em:1001:1001::0:0:Xavier J. B. L.:/home/xan:/usr/local/bin/bash What is that? Why not $2a$? Note that I'm sure I have blowfish encryption, because I have :passwd_format=blf: in /etc/login.conf and I run # cap_mkdb /etc/login.conf.
This is also Blowfish, but of a newer version. You can look at the history of codes and reasons for new versions here: https://en.wikipedia.org/wiki/Bcrypt
What is $2b$ in /etc/master.passwd [duplicate]
1,453,903,263,000
Let's say that you have ~/passwords.txt file where you store all your passwords. How to Best secure the file, so that only you can read/write this file with some "master password"? Securely backup this file (e.g. to flash drive)? Which conditions should be fulfilled, so that this technique will be bullet-proof.
Which conditions should be fulfilled, so that this technique will be bullet-proof. Sane database layout (not a text file) and established safe cryptography. As much as important, ease of use, and little chance to do something bad by mistake. Ideally, instead of just a master password, usage of a hardware token (like a Yubikey) to ensure safe encryption, even if someone should get to know your password. So: Clear job for a password manager, not a plain text file (and a proper database being what's encrypted, to avoid delimiter pitfalls): you want something using a well-tested cryptographic library to encrypt your passwords. There's many popular password managers that are available across multiple platforms. All of them (at least the useful ones) have either trivial to backup single file databases, or a specific export/import/backup functionality. People like KeePassXC. I think it's good for beginners, so that'd be my recommendation. There's KeePassDX as well, which is probably a good choice if you need passwords on your android phone. It has the same database format. Haven't tried it, but in general, doing this on android is probably safer than doing it on usual desktop Linux systems – Android's inter-application separation is pretty good, whereas processes running as the same user on POSIX-style Linux systems have practically no secrets from each other.
Protect and backup a file with passwords
1,453,903,263,000
I recently came across the Linux password change method via the GRUB by entering single user mode. After some digging around I found some articles on how to secure it with a sha512 hashed password.While this sounds like a good option to secure GRUB I also read you can simply change it using a Linux installation. So how can you go about securing the password in a way that cannot be modified or removed through the use of a Linux installation?
So how can you go about securing the password in a way that cannot be modified or removed through the use of a Linux installation? This is not possible. If someone has physical access to your device, they can do everything. You have two options: Encrypt all the partitions and boot from e.g. a USB stick which only you have access to. With new GRUB releases if you have secure EFI [boot] enabled, you can encrypt all the partitions and leave only the EFI boot partition unecrypted with no GRUB password at all. Obviously you'll have to set the password to access BIOS cause otherwise the attacker may disable secure boot or install their own MAC key and tamper with the boot loader and sniff your passwords. Lastly if someone has physical access to your PC they may tamper with your keyboard and install a hardware keylogger - then all your protections are worthless. Protecting your device from physical attacks is a very complicated topic. Maybe you should settle on recently released Apple devices or Android phones which do it perfectly. A run of the mill x86 PC/laptop is wide open to all sorts of physical undetectable attacks.
Securing GRUB password from linux installation
1,453,903,263,000
I have this script I run from a Linux machine to change root password on remote Solaris machine reachable by ssh. All seems to be fine, passwd command asks for a password, second password, reply that is not 8 chars long and finishes with ... updated successfully, but when I go to Solaris and I check, password is not changed. shadow file is not modified. I can change password directly on the Solaris box with no problems. $ cat ./expect2.txt #!/usr/bin/expect -- # Input: username password hostname set USER [lindex $argv 0] set PASS [lindex $argv 1] set IP [lindex $argv 2] spawn ssh user1@$IP expect "user1" spawn sudo passwd $USER expect "assword:" send "$PASS\r" expect "assword:" send "$PASS\r" expect eof exit exit I run the script: $ expect ./expect2.txt root abc123 host1 spawn ssh user1@host1 host1 user1 : spawn sudo passwd root Changing password for user root. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. Debug $ expect -d ./expect2.txt root abc123 host1 expect version 5.45.4 argv[0] = expect argv[1] = -d argv[2] = ./expect2.txt argv[3] = root argv[4] = abc123 argv[5] = host1 set argc 3 set argv0 "./expect2.txt" set argv "root abc123 host1" executing commands from command file ./expect2.txt spawn ssh user1@host1 parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {2669765} expect: does "" (spawn_id exp4) match glob pattern "user1"? no match glob pattern "user1"? yes expect: set expect_out(0,string) "user1" expect: set expect_out(spawn_id) "exp4" spawn sudo passwd root parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {2669769} expect: does "" (spawn_id exp7) match glob pattern "assword:"? no Changing password for user root. New password: expect: does "Changing password for user root.\r\nNew password: " (spawn_id exp7) match glob pattern "assword:"? yes expect: set expect_out(0,string) "assword:" expect: set expect_out(spawn_id) "exp7" expect: set expect_out(buffer) "Changing password for user root.\r\nNew password:" send: sending "abc123\r" to { exp7 } expect: does " " (spawn_id exp7) match glob pattern "assword:"? no BAD PASSWORD: The password is shorter than 8 characters Retype new password: expect: does " \r\nBAD PASSWORD: The password is shorter than 8 characters\r\nRetype new password: " (spawn_id exp7) match glob pattern "assword:"? yes expect: set expect_out(0,string) "assword:" expect: set expect_out(spawn_id) "exp7" expect: set expect_out(buffer) " \r\nBAD PASSWORD: The password is shorter than 8 characters\r\nRetype new password:" send: sending "abc123\r" to { exp7 } passwd: all authentication tokens updated successfully. expect: read eof expect: set expect_out(spawn_id) "exp7" expect: set expect_out(buffer) " \r\npasswd: all authentication tokens updated successfully.\r\n"
This starts a remote session to the host represented by $IP: spawn ssh user1@$IP expect "user1" This starts a new session to change the password for the user represented by $USER: spawn sudo passwd $USER expect "assword:" Note that the two sessions are independent of each other, and you are changing the password for $USER on the local host. You probabably intended send rather than spawn.
expect script doesn't change password on Solaris
1,453,903,263,000
I downloaded Fedora 27 for Virtualbox (.box file) from this webpage https://app.vagrantup.com/fedora/boxes/27-atomic-host, but cannot find the default username and password. I tried username fedora with password fedora, passw0rd, and tried without a password but all failed. Someone advise to set the default password myself but cannot find how to do that.
Default username and password for Vagrant boxes is vagrant/vagrant (root password is also vagrant) but you shouldn't need it, vagrant up inserts SSH key to the machine and you should use vagrant ssh to login to it without password. Also Fedora 27 is no longer supported, its support ended in 2018, you should use latest version (33).
default username and password for Fedora 27 for Virtualbox
1,453,903,263,000
My goal I have an old MySQL database with usernames and passwords hashed using sha256. I don't have the original passwords and it is not possible to learn them. This is a simple user migration from a database to a Linux system. I need to create all those users on linux, because that linux authentication will be used in other part, and we don't want to make users create credentials again. My thoughts so far I have seen that you can use crypt to generate that strange base64 format that uses the shadow file, but that requires the original password. I understand the process is like this in Linux: Generate a simple sha512 hash based on the salt and password Loop 1000 5000 times, calculating a new sha512 hash based on the previous hash concatenated with alternatingly the hash of the password and the salt. Additionally, sha512-crypt allows you to specify a custom number of rounds, from 1000 to 999999999 Use a special base64 encoding on the final hash to create the password hash string. Ref: https://www.vidarholen.net/contents/blog/?p=33 Since the first step is generating the hash with the salt, I think it should be possible. Since linux is open source I believe I could try to get the source code of crypt somewhere like this https://code.woboq.org/userspace/glibc/crypt/crypt-entry.c.html and start in step 2, but before doing all that I don't know if it will work out, I was wondering if there is an easier way. If there is not, where could I get the correct source code of linux for doing that? I am not sure if the link I provided is correct. Thanks a lot.
No, sorry, you can't use the old hash directly to generate the new one. For one, you're talking about having the SHA-256 hash, and then using that to calculate a SHA-512 based hash, which won't happen without inverting the SHA-256 hash. Second, even if you were to use the crypt algorithm based on the same hash ($5$ for the SHA-256 based crypt), pretty much the first step in your link is still "Start by computing the Alternate sum, sha512(password + salt + password)", and for that, you need the plaintext password. The way to make the transition from one password hash to another work, is to either force your users to refresh their passwords in some way that lets you generate the new hashes; or more nicely, modify the login routine so that it accepts a login against the old hash if the new one doesn't exist, and at the same time generates the new hash. That way you can eventually retire the old hashes, except for accounts that are forgotten.
How can I use existing password-sha256, to allow login authorisation?
1,453,903,263,000
When you use a password manager (client side) on linux, I read that you should place the password database in a directory with OWNER and GROUP "passman" or something. Then do the same to the password database files... That's fine, I can do that. So then only the password manager can read or write the file or even see in that directory (besides root). But how is that password manager supposed to be able to access it? Like how do I tie the manager into the group??
You would run the password manager program with the same user & group (or their IDs) so that the program can manage the associated files and directories. This is a very common practice for programs that run as services. A number of such programs automatically set up a user & group during the installation process, and then include the configuration to run as the same user & group. Examples include the Apache web server, Docker, and the Postgres database. The actual switching process varies from one software to the next. Some have configuration parameters to accept the user/group names, and then change to it programmatically. Others use systemd's capabilities to run as a specific user and group. I am sure that there are even more options available.
Creating a group specifically for password manager, how does that work?
1,453,903,263,000
I've noticed that the PASS_MIN_LEN is missing from the password aging controls section inside /etc/login.defs (Ubuntu 20.04 LTS). At the end of the file there is a note that it's obsolete, alongside other options, and someone needs to edit the appropriate file in /etc/pam.d directory. ################# OBSOLETED BY PAM ############## # # # These options are now handled by PAM. Please # # edit the appropriate file in /etc/pam.d/ to # # enable the equivelants of them. # ############### But even if I cat /etc/pam.d/* | grep "PASS_MIN_LEN" I still cannot find this option! What's up with that?
Pluggable Authentication Modules (PAM) is a (not really) newer generic API for authentication originally proposed by Sun Microsystems in 1995 and adapted a year later on the Linux ecosystem. With an API change, don't expect things to keep the same name (nor to always map exactly the same). from man pam_unix: OPTIONS [...] minlen=n Set a minimum password length of n characters. The default value is 6. The maximum for DES crypt-based passwords is 8 characters. Implementation can vary from distribution to distribution. On Ubuntu (like on Debian), /etc/pam.d/passwd will source /etc/pam.d/common-password where the first password occurence includes the useful options. It can be altered and have an minlen=X parameter added. This later file is autoregenerated by pam-auth-update typically on upgrades, so check it works after an upgrade of PAM-related packages. Normally it should: The script makes every effort to respect local changes to /etc/pam.d/common-*. Local modifications to the list of module options will be preserved, and additions of modules within the managed portion of the stack will cause pam-auth-update to treat the config files as locally modified and not make further changes to the config files unless given the --force option. Other options might still affect the result. Eg, if you set minlen=1, the obscure option will still reject a one-letter password as a palindrome, or a 2-letters password as too simple etc. Be careful when altering PAM: you might lock yourself out of your system in case of wrong settings.
PASS_MIN_LEN missing from login.defs
1,453,903,263,000
I'm trying to use expect to automate my login process in ovpn but due to some mistake it is not going well. My script: #!/usr/bin/expect -f set timeout -1 spawn openvpn --config ./bin/openvpn-lib/cert.ovpn --dev ovpntun0 --up ./bin/openvpn- lib/update-resolv.conf --down ./bin/openvpn-lib/update-resolv.conf --script-security 2 expect "Enter Auth Username:" send "myuser\n" expect "Enter Auth Password:" send "mypass\n" interact WHen I try to run it the scriptit reports the following error: vpn_expect.sh: line 4: spawn: command not found couldn't read file "Enter Auth Username:": no such file or directory vpn_expect.sh: line 8: send: command not found couldn't read file "Enter Auth Password:": no such file or directory vpn_expect.sh: line 12: send: command not found vpn_expect.sh: line 14: interact: command not found vfbsilva@rohan ~ $
Expect scripts must be run with expect as expect <script_name> Running them as shell scripts with sh <script_name> Was the cause of the problem.
Expect script hanging
1,453,903,263,000
I need to add new users who are only supposed to be usable through SSH. When adding a user, they get added to the shadow file with an exclamation mark (!) instead of an asterisk (*), so they are "disabled" and sshd does not allow them to be used. Is there a way to add a user without a password that is enabled by default? I have tried using busybox' adduser command and it adds them with a !. Similarly, Gentoo's default useradd command will add them with a !.
Looks like I can specify the encrypted password to add the user with useradd -p '*' testuser It wasn't working previously because I forgot that the shell tried to expand the asterisk when I was missing the single quotes. It looks like I could also use usermod -p '*' testuser on an existing user to set the password to an asterisk as well.
Add new user without password but not disabled
1,453,903,263,000
I was checking my password status and noticed that instead of NP or P there was a L returned so i checked the man pages and found it was a locked password could someone explain what this is to me?
From the passwd manual on an Ubuntu system: -S, --status Display account status information. The status information consists of 7 fields. The first field is the user's login name. The second field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P). [...] Getting L back from passwd --status hence means that the user's password has previously been locked with passwd --lock: -l, --lock Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it adds a ! at the beginning of the password). Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970). Users with a locked password are not allowed to change their password. This means that an account with a locked password still has the old password associated with it, but in a disable form (it's invalid). The user may still log in through other means that do not involve using this password (e.g. through SSH with key authentication). If an administrator unlocks the password, the old password is then again usable for logins.
What does the L returned from passwd --status mean
1,453,903,263,000
Inspired by this answer, I'm wondering if there is a (relatively) painless way to "hide" the wifi password(s) that is/are present in the /etc/wicd/wireless-settings.conf file. I travel a lot and worry that, if my laptop is stolen, a perp could boot said machine with a Live Linux OS and then easily steal said network password(s). Yeah, I know that I'd have lots of other things to worry about, but am looking for a solution to this specific problem...and all of my sensitive user data reside in encrypted files anyway.
2 things come to mind. Wouldn't they need your password to gain access to the contents of your laptop? You might also consider MAC (address) filtering as an alternative to password/wep/... exchanges. IOW whitelist filtering against select MAC addresses. Tho 2 assumes you are in control of the WiFi portal/server. In the end IMHO I think not having access to the contents of your laptop makes the whole issue moot. ;) HTH
Encrypting Wifi Password When Using Wicd
1,453,903,263,000
I was reading about changing root password in CentOS 7. it's totally different from centOS 6. change root password I was wondering about the steps for example why should I change ro? what exactly happens in every step?
ro option means read-only, so changing to rw init=/sysroot/bin/sh in kernel-image will open a shell and now your file-system is mounted with read and write. Now chroot /sysroot means that /sysroot directory will appear as /. For more info regarding this read this answer https://unix.stackexchange.com/a/413790/255251.
change root password in CentOS 7 [duplicate]
1,453,903,263,000
When I upgraded Ubuntu 16.04 to 18.04, one of the changes was that the password prompt to unlock my ssh key (from the agent) now is in a little GUI popup instead of at the terminal prompt. This is inconvenient; sometimes the popup appears behind the terminal and I don't spot it and sometimes I ssh into my machine without window forwarding and then authentication just fails. Can I get old behavior back? I just want it to take the password at the prompt. (I know I can ssh-add ~/.shh/id_rsa for a password prompt in the terminal but sometimes I forget to do that until after I have issued the offending command)
I assume you updated the gnome-keyring, which is providing you the prompts for the PIN if the key was not unlocked before. If that popup appears behind the other windows, there is certainly something wrong with your desktop environment. Can you share the screenshot how the windows look like? There are several things that you might want to achieve: enter passphrase for your key always - kill the ssh-agent or gnome-keyring, unset the SSH_AUTH_SOCK environment variable in your .bashrc. Remember the passphrase for a session -- kill the gnome-keyring, start the normal ssh-agent set AddKeysToAgent to yes.
How to go back to entering the ssh key password in the terminal
1,453,903,263,000
I want to generate 100 files with 100 random passwords in /mnt/mymnt/passwords using a script creating some directories. Even if i try to use cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1 > some_random_file.txt the process just does not stop, anyone has any idea why?
I would do it in the following way: #!/bin/bash for i in {1..100} do cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i done
Trying to generate random password characters into a file
1,453,903,263,000
I got the following bash script to mount a share on my machine: #!/bin/bash BA_LAST_OCTET=144 BA_IP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}' | awk -F'.' '{print $1,$2,$3"."}' OFS='.')$BA_LAST_OCTET PROMPT="Sudo password: " CAN_I_RUN_SUDO=$(sudo -n uptime 2>&1|grep "load"|wc -l) if [ ${CAN_I_RUN_SUDO} -le 0 ] then . getpass.sh $1 echo $PASSWORD | sudo -S : >/dev/null 2>&1 fi OUTPUT=$(sudo mount.cifs //$BA_IP/huginn/ /mnt/huginn/ -o username=fileshare,password="",rw,file_mode=0777,dir_mode=0777 2>&1) if [ -z "$OUTPUT" ]; then HUGINN="Huginn... Mounted." else HUGINN="Huginn... Error.\n"$OUTPUT fi OUTPUT=$(sudo mount.cifs //$BA_IP/muninn/ /mnt/muninn/ -o username=fileshare,password="",rw,file_mode=0777,dir_mode=0777 2>&1) if [ -z "$OUTPUT" ]; then MUNINN="Muninn... Mounted." else MUNINN="Muninn... Error.\n"$OUTPUT fi MSG=$HUGINN"\n"$MUNINN"\nFinalized." if [[ $1 == "--gui" ]] ; then zenity --info --title="Blackarmor" --text="$MSG" 2>/dev/null else echo -e "Mounting Blackarmor shares... \n\n"$MSG fi It works perfectly well from command line. But if I try to use it in a Nemo Action it shows the following message: Huginn... Error. sudo: no tty present and no askpass program specified Muninn... Error. sudo: no tty present and no askpass program specified Finalized. . getpass.sh just gets a password from gui or command line and put it in PASSWORD var. It's working ok, even in Nemo Action (I tested it). The Nemo Action looks like this: [Nemo Action] Active=true Name=Mount Blackarmor share Exec=/bin/bash /usr/bin/ba --gui Selection=Any Extensions=any; Anyone know how I can fix this ? I also accept recommendations on how to run this in a better way. The same problem happens if I try to create a launcher pointing to this script on the Desktop without checking "Launch in terminal" option. Edit as @meuh suggested, I tried to change this: . getpass.sh $1 echo $PASSWORD | sudo -S : >/dev/null 2>&1 to this: #. getpass.sh $1 SUDO_ASKPASS=/usr/bin/ssh-askpass sudo -A : >/dev/null 2>&1 but it showed the exact same message. ssh-askpass is the Ubuntu/Mint version of x11-ssh-askpass (I use Mint). Just to remember, it works in a laucher if I check "Launch in terminal". But I really don't like the big window that appears behind and it also doesn't work as a Nemo Action which would be preferable.
Instead of writing your own password-getting command you can ask sudo to run an existing one, such as x11-ssh-askpass which on my Fedora system is in a package of the same name. You would say SUDO_ASKPASS=/usr/libexec/openssh/x11-ssh-askpass sudo -A somecommand and it will popup a gui for you to enter a password. Alternatively, you can be less secure and allow sudo to run a command when there is no tty by editing the sudoers file with sudo visudo /etc/sudoers (be careful: keep a root login somewhere to rescue you if needed) and adding a line: Defaults:myname !requiretty for your username myname. If you need a tty you can use a program like script to provide one whilst running the command, eg: script <<<'SUDO_ASKPASS=/... sudo -A mycommand' You would probably need to surround your entire script with script, or you would get a new tty each time, and sudo would ask you for a password each time.
Nemo action error: sudo: no tty present and no askpass program specified
1,453,903,263,000
When I try to change user (starting as postgres user) using the command sudo -i -u ubuntu The password for postgres is prompted. Now the postgres account was created upon installing postgres, and I don't know what the password is. I have tried changing the password in the psql prompt with ALTER USER postgres PASSWORD 'password'; ALTER ROLE postgres PASSWORD 'password'; ALTER USER postgres WITH PASSWORD 'password'; ALTER ROLE postgres WITH PASSWORD 'password'; \password ; These have enabled me to set the password for the database server login, but not for the linux user, which makes sense I guess. And trying it with the passwd command doesn't work because it asks for the old password first. I have added postgres to the /etc/sudoers file as well.
The Unix user postgres and the PostgreSQL user postgres are only related by their names, but otherwise are not the same thing. To be able to change to another user with sudo from the postgres Unix user account, you will either have to assign the postgres user a password, or allow the user to use sudo in that way without a password (not something I would recommend). To reset the postgres user password, as root, use # passwd postgres
Fail to change user from postgres to other
1,501,194,888,000
Note: I'm not going to put output of commands because thread will be very long. Solutions I have already tried didn't succeeded to make the desired output. If anybody knows is it possible to get a wordlist of passwords that are 8 characters long (only Uppercase letters, no numbers, no special characters), but without repeating letters in a line, for example: QWERTYUI →→→ good QQWERTYU →→→ bad QQQWERTY →→→ bad QQQQWERT →→→ bad QQQQQWER →→→ bad QQQQQQWE →→→ bad QQQQQQQW →→→ bad Is there any options with "John The Ripper" to make output wordlist like above or maybe pipe to aircrack-ng? I've tried crunch and didn't manage to do that. If is possible I would like to know?
If you have a file with words, and you'd like to delete all words that contain repeated characters, then this will do that for you: $ cat file HELLO WORLD $ sed '/\(.\)\1/d' file WORLD This could be part of a pipeline: $ generate_words | sed '/\(.\)\1/d' | use_words Where generate_words is some program that generates words, one per line, on standard output, and use_words is some program that reads words, one per line, from standard input. The regular expression \(.\)\1 will match any line of input that contains twe consecutive characters that are the same. The d command of sed will delete such lines.
John the Ripper - password without repeating letters
1,501,194,888,000
I wondering where are places luks key password. For example password for root is in etc/shadow. Where I can find file with luks key password? I add this cryptsetup luksAddKey --key-slot 1 /dev/sda5 what is directory of file with this password?
The key material is stored after the LUKS partition header (so no file). The key slots can be viewed using: cryptsetup luksDump /dev/<your_disk> See: https://gitlab.com/cryptsetup/cryptsetup/wikis/LUKS-standard/on-disk-format.pdf
Directory to file with Luks key password
1,501,194,888,000
i am having a file, which contains usernames and encrypted passwords (openssl passwd) in the format user:password. Now i want to change the password of this User with a Cronjob once a week. With the help of Janos i made a Script, which changes the password to a $RANDOM generated value, and saves the encrypted password in pw.txt, and the non-encrypted in randompw.txt r=$RANDOM cut -d: -f1 pw.txt | while read -r user; do echo "$user:$(openssl passwd $r)" done > newpw.txt mv newpw.txt pw.txt echo $r > randompw.txt So my problems are: 1.) With this, i just have a random generated value for each users, but i want a random value for each user (each line in the file). 2.) It would be good, if i can get the username and the cleartext password of each user into randompw.txt currently, i just have one $RANDOM Password there. Does anyone has an Idea? Old post
You can save the generated password in a variable, and write it two files: One file in clear One file hashed For example: # initialize (truncate) output files > clear.txt > hashed.txt cut -d: -f1 pw.txt | while read -r user; do # generate a hash from a random number hash=$(openssl passwd $RANDOM) # use the first 8 letters of the hash as the password pass=${hash:0:8} # write password in clear formats to one file, and hashed in another echo "$user:$pass" >> clear.txt echo "$user:$(openssl passwd $pass)" >> hashed.txt done
Password change Script
1,501,194,888,000
What is the proper way of delivering credentials in passwordless ssh systems (linux)? By passwordless I mean login using only SSH keys. Should I generate pair of ssh keys and deliver it to new user, or allow to login once using password and force (somehow) new user to generate ssh key or append existing public key?
you should let the user generate the key pair, and send you the public key so that you can add it to the list of authorized keys for passwordless authentication. the user's private key is, well, private :-)
Proper way of creating new accounts in passwordless systems [closed]
1,501,194,888,000
ssh is still asking for a password, even though I did everything by the book. I have included all output, right from the start. Any ideas? Thanks! Gary Generating public/private rsa key pair and checking permissions on local host Edit: => As it turned out, this was the problem. The key pair needed to be generated on the remote machine, not on the local machine, as «Mat» pointed it out in the very first comment. Please read the many comments in the solution if you need to know how we got there. on local computer: mms: admin$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/Users/admin/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/admin/.ssh/id_rsa. Your public key has been saved in /Users/admin/.ssh/id_rsa.pub. The key fingerprint is: SHA256:ekIFdhbYVGnWsRcpyhPXRPDF5LTqYI+u6l3URsIjC90 [email protected] The key's randomart image is: +---[RSA 2048]----+ | o+=o.oo*+++| | ..+o B +oo=o| | ..* E.oo..| | .. * =.. | | . S. = + | | . . o * | | o . o o | | o. o | | .o.o.. | +----[SHA256]-----+ mms: admin$ pwd && ls -al /Users/admin/.ssh total 16 drwx------ 4 admin staff 136 Dec 26 09:37 . drwxr-xr-x+ 32 admin staff 1088 Dec 26 08:53 .. -rw------- 1 admin staff 1675 Dec 26 09:37 id_rsa -rw-r--r-- 1 admin staff 401 Dec 26 09:37 id_rsa.pub Copying public key:   (from remote host, because remote host cannot be remotely accessed) server:.ssh ahase$ scp [email protected]:.ssh/id_rsa.pub ~/.ssh/authorized_keys The authenticity of host 'domain-of-local-computer.com (123.456.789.012)' can't be established. RSA key fingerprint is 1f:14:32:84:c4:f8:4e:25:df:2d:56:49:e6:e5:79:1d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'domain-of-local-computer.com,123.456.789.012' (RSA) to the list of known hosts. Password: id_rsa.pub 100% 401 0.4KB/s 00:00 Copying private key and checking permissions:    Edit (as per suggestion) server:.ssh ahase$ scp [email protected]:.ssh/id_rsa ~/.ssh/id_rsa Password: id_rsa 100% 1675 1.6KB/s 00:00 server:.ssh ahase$ ls -al server:.ssh ahase$ scp [email protected]:.ssh/id_rsa ~/.ssh/id_rsa Password: id_rsa 100% 1675 1.6KB/s 00:00 server:.ssh ahase$ ls -al total 24 drwx------ 5 ahase staff 170 26 Dez 12:07 . drwxr-xr-x+ 18 ahase staff 612 10 Dez 09:19 .. -rw------- 1 ahase staff 401 26 Dez 09:58 authorized_keys -rw------- 1 ahase staff 1675 26 Dez 12:07 id_rsa -rw-r--r-- 1 ahase staff 410 26 Dez 09:58 known_hosts ssh still asking for password (-vvv output) [edit after suggested changes] server:.ssh ahase$ ssh -vvv [email protected] OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009 debug1: Reading configuration data /etc/ssh_config debug2: ssh_connect: needpriv 0 debug1: Connecting to domain-of-local-computer.com [123.456.789.012] port 22. debug1: Connection established. debug1: identity file /Users/ahase/.ssh/identity type -1 debug3: Not a RSA1 key file /Users/ahase/.ssh/id_rsa. debug2: key_type_from_name: unknown key type '-----BEGIN' debug3: key_read: missing keytype debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug2: key_type_from_name: unknown key type '-----END' debug3: key_read: missing keytype debug1: identity file /Users/ahase/.ssh/id_rsa type -1 debug1: identity file /Users/ahase/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.9 debug1: match: OpenSSH_6.9 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.2 debug2: fd 3 setting O_NONBLOCK debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: found hmac-sha1 debug1: kex: server->client aes128-ctr hmac-sha1 none debug2: mac_setup: found hmac-sha1 debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug2: dh_gen_key: priv key bits set: 158/320 debug2: bits set: 1048/2048 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug3: check_host_in_hostfile: filename /Users/ahase/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug3: check_host_in_hostfile: filename /Users/ahase/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug1: Host 'domain-of-local-computer.com' is known and matches the RSA host key. debug1: Found key in /Users/ahase/.ssh/known_hosts:1 debug2: bits set: 1023/2048 debug1: ssh_rsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /Users/ahase/.ssh/identity (0x0) debug2: key: /Users/ahase/.ssh/id_rsa (0x0) debug2: key: /Users/ahase/.ssh/id_dsa (0x0) debug1: Authentications that can continue: publickey,keyboard-interactive debug3: start over, passed a different list publickey,keyboard-interactive debug3: preferred 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: Trying private key: /Users/ahase/.ssh/identity debug3: no such identity: /Users/ahase/.ssh/identity debug1: Trying private key: /Users/ahase/.ssh/id_rsa debug1: read PEM private key done: type RSA debug3: sign_and_send_pubkey debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,keyboard-interactive debug1: Trying private key: /Users/ahase/.ssh/id_dsa debug3: no such identity: /Users/ahase/.ssh/id_dsa 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 debug2: we sent a keyboard-interactive packet, wait for reply debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 1 Password: debug3: packet_send2: adding 32 (len 21 padlen 11 extra_pad 64) debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 0 debug3: packet_send2: adding 48 (len 10 padlen 6 extra_pad 64) debug1: Authentication succeeded (keyboard-interactive). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Requesting [email protected] debug1: Entering interactive session. debug1: client_input_global_request: rtype [email protected] want_reply 0 debug2: callback start debug2: client_session2_setup: id 0 debug2: channel 0: request pty-req confirm 1 debug2: channel 0: request shell confirm 1 debug2: fd 3 setting TCP_NODELAY debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel 0: rcvd adjust 2097152 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0 Last login: Sat Dec 26 12:22:40 2015 from 123.456.789.012 mms:~ admin$ I can't look into the log files (/var/log/auth.log or /var/log/daemon.log do not exist and I don't know where they are located). Local computer is a Mac running 10.10.5 and remote computer is a Mac running 10.6 (which can't be changed). Thanks!
(I'm wondering if the term "[email protected]" could cause any problems. Thats the name of the local host computer in the local network. fritz.box is the router's name) No, it is just comment. debug1: identity file /Users/name/.ssh/id_rsa type -1 [...] debug1: Trying private key: /Users/name/.ssh/id_rsa debug3: no such identity: /Users/name/.ssh/id_rsa Your client is not using the key. To @Mat comment, on the client, you need accessible ~/.ssh/id_rsa and on the server the ~/.ssh/authorized_keys. You set it up other way round.
SSH still asking for password even after I have tried everything (that I know of)
1,501,194,888,000
I know this is probably a bit of a nube question, but I need some input. So if I use last I can see my IP, and it's also in my auth log whether failed or accepted, eg. Dec 9 19:30:16 wilhelm sshd[14211]: Failed password for root from 59.63.188.44 port 16257 ssh2 I want to know whether it is possible to only allow connections from IP's from a certain ISP. e.g. if I do whois X.X.X.X on my IP and grep for ISP: root@wilhelm:~# whois X.X.X.X|grep <ISPNAME> netname: <ISPNAME> So is it possible to add this to pam for SSH connections? Are there any disadvantages to this approach(except being locked out when in another location(portknocking maybe))? It's on a VPS so I'm not worried about internet dropping out. I can just use VNC if I absolutely have to. I have done a few quick searches on this and I'll continue to.
Not exactly by PAM, but yes, it is possible to do. You can set this up using tcp_wrappers by modifying your /etc/hosts.allow, if your distro provides you the aclexec extension: sshd: aclexec whois %a | grep <ISPNAME> Or you can wrap the command into script that you can easily call. More info can be found in manual page for hosts_options(5).
PAM filtering via IP for SSH
1,501,194,888,000
I need to put one character inside the password file so that nobody can notice. I thought that if I was able to put the password as plain text and put something like a space nobody would ever find out. But I don't know how to put plain text in the /etc/passwd or /etc/shadow file. Is there any way to put just one character or a really short string in there so that if someone opens that file doesn't even notice that for instance gnats has a password. Example: gnats: :16273:0:99999:7::: OR gnats:8:16273:0:99999:7:::
In short, no. The formats of these files are very specific, and the password field strings are hashes which will have a minimum length of 8 characters, 16 or more on more modern versions that use stronger password hashing. If you're looking for a way to just put in a text string, look at the gecos field in /etc/passwd. If you want a way to have an "invisible" password, you're out of luck in dealing with these two files.
/etc/passwd shortest password
1,501,194,888,000
I got an old Mac G4 (powerPC) from the company who wanted to put it in a bin. The company agreed that I can take it home for private use. It is running an early version of OSX but because it is old and the person in charge no more in the company, I do not have any login/password for entering the system. Is there any procedure to either create a new user or to reset the password of an existing user?
You can boot any OS X based Mac into single user mode by holding ⌘-S as it boots. You need to have it pressed by the time it gets to the gray boot screen. Once the gray screen disappears, so that you can see the text mode boot stuff, you can let go. Once you get to a prompt, you can reset the primary user's password. Reboot, and you can then log in as that user. Alternately, download an OS disc ISO appropriate to the machine's age, and reinstall the machine.
Login retrieval in osx [duplicate]
1,501,194,888,000
I use the IceWM window manager. I would like the screen to lock after closing the laptop lid. I've found a couple of guides that looked promising (1, 2) but unfortunately didn't work for me. Maybe there is a solution that I'm currently missing?
IceWM doesn't have a built-in screen lock feature, you'll have to install an extra application for that, e.g. xlock. To invoke xlock on lid close please consult with this answer: suspend AND lock screen on closing lid in arch/systemd
IceWM. How to lock screen after laptop lid is closed?
1,501,194,888,000
info lsh manual covers how to create a keypair and protect the private key with a passphrase. The manual does not tell how to change the passphrase or how to decode the private key, which is stored as a password-encrypted S-expression. Per the manual, lsh-writekey encrypts the private key with the passphrase. But lsh-writekey expects a private-key S-expression similar to what lsh-keygen provides. Otherwise, it outputs something but explains: $ cat ~/.lsh/identity | lsh-writekey -o test-output-file Enter new passphrase: Again: lsh-writekey: spki_make_signer: Expected private-key expression. How do I get the existing private key as a private-key S-expression for lsh-writekey, so that I could set a new password for that private key?
There is a hint at the bottom of man lsh-writekey that there is also lsh-decrypt-key. It has its own manual page. It is not covered in the Texinfo manual for some reason and is not mentioned in the SEE ALSO section of man lsh. You need to move the existing keys or specify a different output file for lsh-writekey because it refuses to overwrite existing private or public key files. Here is how to change the passphrase: $ mv ~/.lsh/identity ~/.lsh/identity.backup $ mv ~/.lsh/identity.pub ~/.lsh/identity.pub.backup $ cat ~/.lsh/identity.backup | lsh-decrypt-key | lsh-writekey You enter the current passphrase for the key and proceed with specifying the new passphrase.
How to change the private key passphrase in lsh?
1,678,980,594,000
I need a way to generate a random password following this requirements: Password at least 9 characters at least 2 capital letters at least 2 small letters at least 2 digits at least 2 special characters must start with a letter this is the command that I have: { shuf -r -n4 -e {A..Z}; shuf -r -n4 -e {a..z}; shuf -r -n4 -e {0..9}; } | shuf | tr -d $'\n' but is missing the special characters OS is SuSE 12
You could add the special characters with another shuf, just can't use brace expansion and ranges like that. But you could explicitly list them, one by one, quoted to protect them from the shell: shuf -r -n2 -e '!' '"' '#' '$' % '&' '(' ')' '*' + , - . / : ';' '<' = '>' '?' @ '[' '\' ']' '^' _ '{' '|' '}' Or shove them in a string and use word-splitting to get them into multiple arguments. Need to disable globbing with set -f, though, otherwise the asterisk will cause issues: set -f shuf -r -n2 -e $(sed -e 's/./& /g' <<< '!"#$%&()*+,-./:;<=>?@[\]^_{|}' ) (or just do what everyone does, and add two fixed special characters at the end of an otherwise sensible password that's long enough even without them.) To make sure you have a letter as the first character, it's easiest to just add one separately, and shuffle the characters of only the rest of the password. E.g. this would build the password in two pieces, the first being a single letter (upper or lower case), the second is what you had in the comments: #!/bin/bash set -f pw=$(shuf -r -n1 -e {A..Z} {a..z}) pw="$pw$( { shuf -r -n4 -e {A..Z}; shuf -r -n4 -e {a..z}; shuf -r -n4 -e {0..9}; shuf -r -n2 -e $(sed -e 's/./& /g' <<< '@%+\/!#$^?:.(){}[]-_.'); } | shuf | tr -d '\n' )" echo "$pw" The output would be something like this: $ bash pw.sh WRgpJ7pP%Tj60.1 $ bash pw.sh oV6N#7s4Po3Bt)r
How to create a random complex password in SuSe 12
1,678,980,594,000
I have created a few accounts on my Linux Mint installation. A few of them have admin privileges. About 30 min ago I changed the password on one of the admin accounts using the Users Settings GUI. But I am still seeing the spinning circle. I have a few questions in that regard. How long do I need to wait to ensure that the password has changed? What will happen if I reboot the system while the GUI is still showing the spinning circle? I try to change passwords every so often. How do I speed up the process the next time?
How long do I need to wait to ensure that the password has changed? You don't, this shouldn't happen, something is wrong with your system. Password change should be instantaneous. Inspecting journalctl logs could help you understand what's going on. What will happen if I reboot the system while the GUI is still showing the spinning circle? If it's already taken so long, I am pretty sure some component has timed out/frozen and nothing bad will happen if you reboot. I try to change passwords every so often. How do I speed up the process the next time? Do it from console using passwd.
Why is changing password on user account is taking time?
1,678,980,594,000
I'm an admin of a virtual machine and I've added a user (let's call it myuser) to it. I've also deleted its password (see chain of commands below) at the end of the process, but it still asks for a password (which doesn't exist, so it fails. Everything is working fine with the ssh keys. This is only happening when the user is running Mac OS (I've done the exact same steps for a user on Ubuntu and it works as expected).. sudo useradd -m myuser sudo usermod -aG sudo myuser sudo passwd myuser (Password is set to "123test") sudo su myuser sudo mkdir ~/.ssh sudo chmod 0700 ~/.ssh sudo chown myuser:myuser ~/.ssh sudo touch ~/.ssh/authorized_keys sudo chmod 0644 ~/.ssh/authorized_keys sudo vim ~/.ssh/authorized_keys (Paste public ssh key) sudo passwd -d -l myuser Current result: User ssh-es into the vm and gets prompted for a password (that doesn't exist, so it fails) Expected result: User ssh-es into the vm and is taken right into the vm terminal.
After following Peder's advice, I saw that the user was missing permissions to their ssh folder. Changing the /var/root/.ssh permission to the user on the mac computer solved the issue.
Why is my virtual machine still asking a user for password after I deleted its password?
1,678,980,594,000
I use gpg-agent to manage ssh-agent. On my PC: ssh-add -L prints my public keys which is used on the server. ForwardAgent is open. pam.d/sudo and sudoers are configured. After ssh user@host, echo $SSH_AUTH_SOCK print the gpg-agent one. If running sudo -i or other command with sudo, it asks password. If using ssh user@host 'bash' or other shell, then sudo can run without asking password. By the way, this method will not print any prompt of shell, such as $ . Set pam.d/sudo with auth ... debug, and get the log: Nov 10 16:46:23 nixos sudo[30150]: pam_ssh_agent_auth: Beginning pam_ssh_agent_auth for user vonfry Nov 10 16:46:23 nixos sudo[30150]: pam_ssh_agent_auth: Attempting authentication: `vonfry' as `vonfry' using ~/.ssh/authorized_keys:~/.ssh/authorized_keys2:/etc/ssh/authorized_keys.d/%u Nov 10 16:46:23 nixos sudo[30150]: pam_ssh_agent_auth: Contacted ssh-agent of user vonfry (1000) Nov 10 16:46:23 nixos gpg-agent[4022]: scdaemon[4022]: pcsc_establish_context failed: no service (0x8010001d) Nov 10 16:46:23 nixos sudo[30150]: pam_ssh_agent_auth: Failed Authentication: `vonfry' as `vonfry' using ~/.ssh/authorized_keys:~/.ssh/authorized_keys2:/etc/ssh/authorized_keys.d/%u On the server, gpg-agent is listed in htop owned by my ssh login user and gpg-connect-agent can work. TTY and GPG_TTY are the same. htop showed gpg-agent has a subprocess scdaemon --multi-server I tried to search around gpg-agent[4022]: scdaemon[4022]: pcsc_establish_context failed: no service (0x8010001d), but got nothing useful. EDIT1: If I kill the ssh login user's gpg-agent daemon, the sudo can work without password.
I find the reason. My interactive shell script re-export the SSH_AUTH_SOCK variable which override the original one from sshd.
pam_ssh_agent_auth: sudo asks for password with ssh user@host, but ssh user@host 'bash' not
1,678,980,594,000
My company has a Debian server that holds and runs some important stuff that cannot be shut down... The previous Joe before me, didn't seem to have a password logged or even passed on the information about it, so we're at a loss. Is there a way to recover/change/get into the computer files without resetting the server?
No, of course not! That would made Debian Linux very untrustworthy :) You could try to crack/hack the server. If you're lucky and a non-complicated password for root (or a sudoer user, if it's a system without root user) was used, and no advanced security mechanisms applied, you could use John the Ripper to crack passwords. Another option would be to locate vulnerabilities, especially if it's an older version and was left unpatched. The latter seems highly possible, since nobody even cared to log in - what are the odds to be set to auto update; surely it wasn't updated manually without someone logging in. You could use metasploit for this task. Exploit one or more vulnerabilities and gain access. You could start with a simple port scan using nmap. Sometimes daemons, services run without anybody noticing which could give you some access, somewhere. A clarification, you need access to files only, you don't care about logging in to the server? Don't you have anything, not even a user/passwd for ssh, or samba? NFS shares to at least access some part of the filesystem?
Resetting Debian Password without restarting at all? [duplicate]
1,678,980,594,000
I am setting up a new system that is running CentOS 7 and Gnome 3.28.2. I've used CentOS from the command line before but this is my first time using Gnome. I have found that Gnome does not seem to remember the password for my Network-Attached Storage. When I connect to my NAS, Gnome asks me for the user name and password. I check the box to save the credentials, but Gnome doesn't actually remember them and asks me again the next time I boot the system and connect to the NAS. I have verified that gnome-keyring and seahorse are installed. Why else might Gnome be forgetting the credentials? Is there something else I need to install?
I figured out a solution. Originally I was reconnecting to the NAS by going to Files > Other Locations > Connect to Server. This always asks for my credentials, even if I check the box to remember them. I got around this by bookmarking the shared folder on the NAS. If I click on the bookmark in Files, it connects and opens the folder immediately without asking for my credentials.
NAS password not saved in Gnome / CentOS 7
1,581,905,517,000
I am looking for a simple, open-source password manager for linux with a CLI. It has to have a way of retrieving a password via the command line, so I can use it in several scripts (that sync my email for example). I came across pass (https://www.passwordstore.org/). It looks very promising and exactly like the program I was looking for, however there is one thing I can't figure out. Using pass git init and pass git push, I can synchronize the passwords to an external git repository. However: this is not enough to use the passwords on a different machine, because the gpg keys are not synchronised. How can I synchronize the gpg keys/pass passwords in a safe way? I found this question: synchronising gnupg and pass but is doesn't really answer my question. It just says "don't put your gpg keys on the web".
In the end, I gave up on trying to make this work and used KeePassXC. Then, in order to obtain a password from KeePass using the command line, I use: gpg2 --use-agent --output - -q passphrase.gpg | keepassxc-cli show -q -a Password passwords.kdbx the_secret_password_i_am_looking_for The passphrase.gpg file contains the KeePass password and is encrypted using a symmetric key, meaning that it only needs a passphrase to unlock it. In my gpg-agent.conf file, I put the following contents: max-cache-ttl 60480000 default-cache-ttl 60480000 display :0 This effectively remembers the passphrase until the end of the session. I hope it is of use to someone. Edit: the synchronization part is done by syncing the KeePass database using Dropbox.
Synchronise passwords across devices with pass
1,581,905,517,000
I have an arm7 board running GNU/Linux, it's connected to the internet via Ethernet port. I am trying to SSH in to it as root@IPaddr but it is prompting me for a password. I am pretty sure the password was never set on it. I actually changed the sudoers file as well with : root ALL=(ALL) NOPASSWD: ALL but no use. I am able to shell in to it via serial port though without getting prompted for a password. I am a little lost. root@mur0011:~# ls -la .ssh/ drwx------ 2 root root 4096 Nov 8 01:10 . drwxr-xr-x 10 root root 4096 Nov 8 01:10 .. -rw------- 1 root root 2347 Jun 1 21:20 authorized_keys -rw------- 1 root root 1675 May 31 23:19 id_rsa -rw-r--r-- 1 root root 397 May 31 23:19 id_rsa.pub -rw-r--r-- 1 root root 803 Jun 1 19:51 known_hosts root@mur0011:~# uname -a Linux mur0011 3.14.38-6UL_ga+ge4944a5 #1 SMP PREEMPT Wed Mar 14 16:48:19 PDT 2018 armv7l GNU/Linux root@mur0011:~# whoami root
The sshd server will always ask for a password, unless you configure it to allow empty passwords. Also, it most current default configurations, sshd is configured to disallow root logins or only allow root using public key authentication. So, you should ensure that root can login through ssh and that empty passwords are allowed: /etc/ssh/sshd_config PermitRootLogin yes ... PasswordAuthentication yes PermitEmptyPasswords yes ... You will also need to set an empty root password. This is not the same thing as no password. No password is defined as either a non-existent password or an illegal password. In either of these cases, an implicit, but impossible to enter, password will be required. This, of course, means that root will not be able to login directly. So, an empty password is what is required. Please note: This is very poor security and should only be used within a trusted network that is not directly accessible from the Internet.
SSH asks for password but I can get in thru serial port without it
1,581,905,517,000
I am using UP Board. IT has Ubilinux installed in it. I have made a browser kiosk so that it automatically logs in to the browser full screen mode but I am having an issue on reboot. Whenever I try to reboot I have to enter a password on Login screen. I want it to be removed so that it can auto logged in without any input from user.
I created a file named sddm.conf in /etc/ directory. I placed this in it. Now I can login without any password. [Autologin] User=up Session=LXDE
Removing login username password screen to Autologin
1,581,905,517,000
Suppose I set my password to something very simple, like the letter 'a', such that anything with access to a login prompt effectively has root access. What attacks does this open me up to, as a desktop Linux user?
It's safe from remote attacks unless you spin up a service that utilizes password authentication. For instance, it would still be safe to allow SSH access to that account with the simple password if password authentication were disabled and keys were used instead. In other words, it's not a problem if it's a home computer in a safe environment.
cost of weak password for single-user desktop [closed]
1,581,905,517,000
Whenever I visit any Index page of any website, it pops up with this notification. I'm using Kali GNU/Linux Rolling.
If your browser is Google Chrome, you may get rid of gnome-keyring in it. Just switch to internal Chrome password storage with --password-store=basic on Google Chrome start: /usr/bin/google-chrome-stable --password-store=basic
how to remove the popup notification of keyring login?
1,581,905,517,000
I want to set up a script that allowes me to display my emails on my bar, but i have to create a file containing my password for it. Is there a way to protect this file from beeing read by anyone, without denying my system the access to that file?
That's easily enough done with standard unix file permissions. Assuming the file is named emailcredentials.ini located in /home/errelion and is owned by the user the script will run as, the command you'll want is chmod 0600 /home/errelion/emailcredentials.ini This will render the file readable and writable to the owner, but inaccessible to anyone else (aside from root, who is the superuser and can do what he or she damn well wants).
Make file readable for system but not users
1,581,905,517,000
So I followed the solution here: command to zip multiple directories into individual zip files and I added -er to the command however as I expected, I need to enter the password for every loop operation, i.e for every folder that gets zipped. How can I automate the password part? I want to use the same password for all zipped files. Thanks EDIT: It would be great if I can have all the output zip files created in another directory
Instead of the -er flag, you could use the -P flag - it expects the password to follow. -P password --password password Use password to encrypt zipfile entries (if any). THIS IS INSE- CURE! Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the- shoulder peeking. Storing the plaintext password as part of a command line in an automated script is even worse. Whenever possible, use the non-echoing, interactive prompt to enter pass- words. (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak standard encryption provided by zipfile utilities.) Note it is insecure because the password is displayed on the command line and potentially viewable by others looking at the process tree. If that's not acceptable, look into using the expect utility. http://expect.sourceforge.net/
Terminal - Zip multiple directories into separate zip files with password
1,581,905,517,000
I had set up a small Linux box a few months ago, and I set up passwordless ssh login for both my personal userid and a service account id. That is working fine for both. I stored the private/public key files for the service account in the same place that I stored the keys for my personal userid, on the client box. I'm using the following for my basic guide: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/ . Today I set up a second box, intending to configure it the same way. I had no trouble getting it to work for my personal userid. However, it's still not working for the service account, but I don't understand why. When I attempt the ssh with the service account to the second box, it prompts me for the password, and then lets me in. I've verified that the public key for the service account is inserted into the ~/.ssh/authorized_keys file on both boxes, and the key value is the same on both boxes. I've verified that ~/.ssh has perms of 700, and that ~/.ssh/authorized_keys has perms of 600 (I've also tested with 640, which is what I've read as the recommended value). I've verified this on both boxes, in the home directory for the service account. Note that the numeric userid for the service account is different on the two boxes. I wouldn't think that would make any difference. I also note that after I ssh to either box with the service account, if I then try to ssh to the OTHER box from that one, using the service account, it prompts me for a password. Do I need to do something with "known_hosts", or something else? Update: As advised, I tried running ssh with "-v" and inspecting the output from the ssh attempt. This is the output, with some elisions: % ssh -v [email protected] OpenSSH_7.2p2, OpenSSL 1.0.2h 3 May 2016 debug1: Reading configuration data /home/myuserid/.ssh/config debug1: /home/myuserid/.ssh/config line 2: Applying options for * debug1: Connecting to targethost.com [...] port 22. debug1: Connection established. debug1: identity file /home/myuserid/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/myuserid/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to targethost.com:22 as 'serviceaccountid' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:... debug1: Host 'targethost.com' is known and matches the ECDSA host key. debug1: Found key in /home/myuserid/.ssh/known_hosts:18 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/myuserid/.ssh/id_rsa debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Trying private key: /home/myuserid/.ssh/id_dsa debug1: Trying private key: /home/myuserid/.ssh/id_ecdsa debug1: Trying private key: /home/myuserid/.ssh/id_ed25519 debug1: Next authentication method: password [email protected]'s password: I find it curious that in the last few lines, after "Next authentication method: publickey", the file path references are to "/home/myuserid", not "/home/serviceaccountid". That seems like a big clue.
I can't add comments with my account, but this is just me trying to learn more to help troubleshoot. It sounds like you have three computers, one local and two remotes. And each of them have two accounts that you're working with? If you have a personal and service account on the local machine and run ssh service@remote-2 from the personal account on your local machine, then it will only find ssh keys for your local personal account, not the service account.. This shouldn't matter if you've added the local-personal public key to the remote-service account's authorized keys file. I find it curious that in the last few lines, after "Next authentication method: publickey", the file path references are to "/home/myuserid", not "/home/serviceaccountid". That seems like a big clue. That's ssh looking for keys in the local account.. It should be the home directory of whatever account you're calling ssh from. If you expect that path to be a service account's home, then you need to log into the service account and then run ssh.
ssh passwordless login mostly working, except for a service account to a second box
1,581,905,517,000
i am using a script to create a random password for a user. The file looks like user1:password1 user2:password2 user3:password3 Passwords are openssl passwd hashed. I have an own file where the password is written in cleartext. No i want to send an E-Mail to the users with the new password. I have a file (maillist.txt) with user1:[email protected] user2:[email protected] user3:[email protected] Now i want to generate an E-Mail to user1. This should generate an E-Mail to [email protected], containing the username (user1) and the password (password1). I want to do it with mailx. Can you please help me? Regards Manu Old post
Try the following: join -t: cleartext.txt maillist.txt | awk -F: '{ print "echo Username: "$1" Passwd: "$2" | mailx -s Information "$3 }' |sh If multi lines are required in the email body, refer below #!/bin/bash >tmp.txt join -t: cleartext.txt maillist.txt | while read line do echo $line USER=$(echo $line | awk -F: '{ print $1 }') PSWD=$(echo $line | awk -F: '{ print $2 }') EMAILID=$(echo $line | awk -F: '{ print $3 }') echo "Hello $(echo $USER | tr a-z A-Z), your password has been changed!!!<br>" >tmp.txt echo "<b>Username</b>: $USER<br>" >>tmp.txt echo "<b>Password</b>: $PSWD<br>" >> tmp.txt cat tmp.txt | mailx -s "$(echo -e 'Password Changed!!!\nContent-Type: text/html')" $EMAILID done
Generate E-Mails with content on different files
1,581,905,517,000
I want to write a script to connect to the server, which will increase the privileges. Now I use a script with expect, but I would like to change that. Here is a way by which I try to achieve this: ssh host -t 'echo "passowrd" | sudo -S echo; sudo -i' Is the password is saved in the command history on server? I can't find any records of these commands: ssh host -t 'ls;echo $SHELL;history;bash -l' This command displays the result of the ls command and "/bin/bash".
use the sudoers (visudo or put a config to /etc/sudoers.d) to provide privileges for the user to execute given commands without password seems to be the better way. if you use not the interactive way (just remote execute and not login) there will be no entry made in bash history. To access the history of bash you need to use this for example: ssh host "cat .bash_history" But you will not find any entries from a remote execution.
Sudo -i with password inside ssh
1,465,882,714,000
What is the cleanest way to require the user to enter password in order to run a particular program without the use of third-party applications? For example, if I type firefox to launch it from the terminal, it will prompt for a password and only run it if the correct password is entered. Something akin to that affect using perhaps user permissions.
create exampleuser , and set password to it then change firefox permissions to 700 and change firefore own to exampleruser ; after this you can run firefox only root or exampleuser with sudo or su command. for exmaple: sudo useradd exampleuser sudo passwd exampleuser sudo chown exampleuser:exampleuser ../firefox sudo chmod 700 ../firefox test: $ ../firefox bash: ../firefox: Permission denied $ su - exampleuser -c ../firefox Password: #<-- type exampleuser password or run with root user: $ sudo ../firefox [sudo] password for username: #<-type root password
Cleanest way to require the user to enter password to run a program?
1,465,882,714,000
Is there any way to set a password on a script (or any file for that matters), without having to enter a specific command line to decrypt it each time I want to edit it? Setting this password to a directory, making every file (present and future) password-protected would be fine, and actually even better. Situation example : nano path/to/script Enter passphrase : ***** [Modification allowed, then file closed] path/to/script/scriptToExecute [Is executed without asking for password] sudo is in itself a solution, but the problem is that unless I leave terminal, it doesn't ask for password when it's been entered once in a single session. The purpose of this would be to connect to a distant SSH without having to type the password every time (mostly to do scp commands actually), hence putting it in the script. But if everyone can access it, it becomes pretty much meaningless. Any idea/solution? Thanks for your answers.
As Jeff Schaller mentions, you can disable the password caching of sudo by adding this to your /etc/sudoers file: Defaults timestamp_timeout=0 Then you can simply chown root FILE; chmod 755 FILE so that only root can edit the file but everyone can read/execute it. Alternatively, you could do su root -c nano FILE, since su does not cache passwords.
Password protected script on editing, no password on executing
1,465,882,714,000
I have website which is password protected where runs a php app on it. Now I have to unprotect a sub-url of that website but without disablng the protection of the main site which is configured through plesk. This sub-url is given by the php app and is not a physical folder. Any hints how I can achieve that? OS Ubuntu 14.04.3 LTS Webserver Apache2 Plesk Version 12.0.18 How do I find where plesk is storing/managing the "RequireUser" directives for my website? I assuming it is writing in somewhere into a vhost.conf? Or does plesk uses a different approach to manage password protected directories?
I could solve my problem by using a ".htaccess" file on my website which then excludes the url. This brings the benefit that I do not have to change anything which is managed by Plesk. The example is valid for apache 2.4 for older version you need to change it accordingly. # Allow access to excluded diretories SetEnvIf Request_URI /shop/api noauth=1 <RequireAny> Require env noauth Require env REDIRECT_noauth Require valid-user </RequireAny>
Ubuntu & Plesk - How to exclude a sub-url from password protection?
1,465,882,714,000
What I have done is set up a virtual machine using AQEMU/KVM of Kali Linux, the problem is that I don't remember either of my log in details user name / password. So, is there a way to view those details through recovery mode, or with an option with AQEMU? If there is multiple ways to do this, please list all of them since I tend to always run into problems.
If you can login as root, or otherwise get a root shell (e.g. with init=/bin/bash on the kernel command line when you boot - you do this from grub), you should be able to view /etc/passwd to see the list of users (most likely your user will be the one with UID=1000) and use passwd username to change the password. if you use the init=/bin/bash method or similar, you will have to remount the root fs as read-write before changing the password. mount -n -o remount,rw / and remount it as read-only again before rebooting mount -n -o remount,ro / If you had to use this method, you will probably need to change root's password too. just run passwd without a username to change the password of the current user (root)
How to view all users and change the password
1,465,882,714,000
While installing CentOS 7, i put password for disk encrypt. Now while working remotely on that machine and doing reboot it always ask password to be inserted on-site. Is this normal? or there is a way still keep disk encrypted but make the reboot work?
It is very normal, and it is because disk is in list of disks to be automatically mounted. If you don't want to be asked for password, you should remove encrypted disk from /etc/fstab. After doing this, you will be prompted for password only when you want to mount encrypted disk. Good luck!
CentOS 7 - while installing i set disk encrypted with password, but on reboot always it asking password
1,465,882,714,000
Last night I SSH'ed to different systems.... one system/SSH reported that the "authenticity of HOSTNAME couldn't be established......." and it asks if I want to continue or something, I didn't and found this peculiar so I tried to SSH to the system from one of the systems I already had SSH access/open, which didn't report that message(which means no change to the system since last login). Then I looked at my ~/.ssh/known_hosts and the system was in there so it should know the host I was connecting from, then tried again using the up/down arrows to browse bash history so I didn't make any mistakes in the commands and I didn't... And this time it worked without any notice about failed authenticity and asked for the password as usual. Should I be worried, was this as Debian say's "someone doing something nasty"? The point is... why the message, then not the message(without me doing or changing anything)..... weird.
It's possible that somebody was trying to spoof that server. It's also possible, and in most environments more likely, that there was a misconfiguration of some kind. Maybe the DNS is misconfigured and has several IP addresses recorded for the same host name. Maybe two machines were competing for the same IP address. Maybe the SSH server on the target machine was temporarily misconfigured.
SSH authenticity couldn't be established
1,465,882,714,000
The delay after a failed password is very long. In /etc/pam.d/login, FAIL_DELAY is configured as auth optional pam_faildelay.so delay=3000000 however, actual delay is about 12s. This affects all places where a password is required - terminal/mdm login, su/sudo in terminal, cinnamon-screensaver (lockscreen), pkexec - everywhere. Even canceling a su/sudo password prompt in terminal with ^C or ^D takes a long time. How can I reduce this failed-password delay time to the actual 3s configured in /etc/pam.d/login ? EDIT: grep '^auth' /etc/pam.d/* /etc/pam.d/chfn:auth sufficient pam_rootok.so /etc/pam.d/chsh:auth required pam_shells.so /etc/pam.d/chsh:auth sufficient pam_rootok.so /etc/pam.d/cinnamon-screensaver:auth optional pam_gnome_keyring.so /etc/pam.d/common-auth:auth [success=2 default=ignore] pam_unix.so nullok_secure /etc/pam.d/common-auth:auth [success=1 default=ignore] pam_ldap.so use_first_pass /etc/pam.d/common-auth:auth requisite pam_deny.so /etc/pam.d/common-auth:auth required pam_permit.so /etc/pam.d/common-auth:auth optional pam_ecryptfs.so unwrap /etc/pam.d/common-auth:auth optional pam_cap.so /etc/pam.d/login:auth optional pam_faildelay.so delay=3000000 /etc/pam.d/login:auth [success=ok new_authtok_reqd=ok ignore=ignore user_unknown=bad default=die] pam_securetty.so /etc/pam.d/login:auth requisite pam_nologin.so /etc/pam.d/login:auth optional pam_group.so /etc/pam.d/mdm:auth requisite pam_nologin.so /etc/pam.d/mdm:auth sufficient pam_succeed_if.so user ingroup nopasswdlogin /etc/pam.d/mdm:auth optional pam_gnome_keyring.so /etc/pam.d/mdm-autologin:auth requisite pam_nologin.so /etc/pam.d/mdm-autologin:auth required pam_permit.so /etc/pam.d/ppp:auth required pam_nologin.so /etc/pam.d/proftpd:auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed /etc/pam.d/su:auth sufficient pam_rootok.so /etc/pam.d/sudo:auth required pam_env.so readenv=1 user_readenv=0 /etc/pam.d/sudo:auth required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0 EDIT: Commenting out pam_faildelay.so has no effect. EDIT: Changing it to 0 has no effect. Changing it to 10000000 has no effect.
@Giles The only potential culprit I see in your configuration is pam_ldap, if LDAP is misconfigured somehow. Yep, commenting it out solved the problem.
Password fail delay is too long - Linux Mint 17
1,465,882,714,000
If I use john for getting weak passwords in ex.: 2010, then can I use the john.pot file later or there could be situations when the hash is the same, but the passwords differ?
Of course, you can use your old john.pot file. Because password hashes of current systems are usually additionally secured by salting and the used hash algorithms are quite strong, is improbable that you find a hash collision. But in the unlikely case, that you find one, both password should work on the target system.
Can the ~/.john/john.pot file be used forever?
1,465,882,714,000
I want to create a cron script to interact with mysql, for example #!/bin/bash mysql -uroot -p echo root echo "CREATE DATABASE example" But it doesn't work, it only prompts: Enter password: and when I exit mysql it shows root "CREATE DATABASE example" Any idea?
Put something like: [client] user=root password="my-very-secret-password" In a file whose permissions ensure that nobody outside the people who are entitled to read it can read it. And run: #! /bin/sh - mysql --defaults-extra-file=/path/to/that/file --batch << "EOF" CREATE DATABASE example EOF See MySQL's own guideline itself for more information. You could put the password in the script and restrict read access to the script itself, but you'd also need to make sure that the password is not passed as argument to any command as that would then make it visible to anybody in the output of ps. You could do something like: #! /bin/sh - mysql --defaults-extra-file=/dev/fd/3 --batch 3<< "END_OF_AUTH" << "END_OF_SQL" [client] user=root password="my-very-secret-password" END_OF_AUTH CREATE DATABASE example END_OF_SQL
Use a password in shell-script
1,465,882,714,000
I have seen people use passwd -l "$USERNAME" , But the linux man page does not explain what the -l option is for. What does it do ?
I got this by issuing the passwd command at the CLI -l, --lock lock the password of the named account It locks the account so that root has to unlock the account before this person can log-in and use the account again. EDIT As it was indicated this is a duplicate of this
What is "-l" option do to the passwd command? [duplicate]
1,465,882,714,000
I'm trying to run FreeBSD (.iso) in a virtual VMWare machine. The useradd command gives me an error: # useradd pstnc useradd: Command not found Why is that? The command is correct and very simple, just put useradd and then the password and that's it. I tried to find a solution here and open a lot of other sites, but in all places talk about of creation of one new user, and none about what to do if it gives you an error like in my case!
The FreeBSD Handbook is an excellent source of information about FreeBSD. The Modifying Accounts section has explicit instructions for adding and removing users.
Error when I want to create a user on FreeBSD
1,465,882,714,000
In a shell/bash script (I use it for vagrant provision), I configure apache2 server and then restart it. But since I use a key file for https, apache asks for a password. How can I automate this and tell the script my password. Could this be done with something like this? sudo apachectl restart <<< "mypassword" (Set aside any security issues: this is only for development and vagrant is insecure by default) P.S. I really don't want to install any additional software, since script should be as lean as possible.
If I understand you correctly, apache2 is prompting for the password to unlock the TLS private key you use for HTTPS? If you don't want that extra security on expense of usability, your best option is to remove the password from the key as described here: stop apache from asking for SSL password each restart You can also provide the password via a file and reference it in the apache configuration as described here: SSL password on apache2 restart However this will reduce having the password in the first place to absurdity.
Shell script "apachectl restart" password automation
1,465,882,714,000
I would like to list the username of the users which do not have a strong password in a LAN. How can I do it? I do not want to force the password of the users, I want to force the users that have no password or not strong one to change it and use a stronger one.
Assuming you have access to the password database, something like John the Ripper could help you. Though it'd be easier to force a sufficient amount of "strongness" when the users set their passwords.
How to list users without a strong password? [closed]
1,465,882,714,000
In the past, I have successfully logged onto a server from my desktop using ftp/sftp. The password was saved somewhere in my system, but I am not sure where. I am now trying to change the password because the password changed on the server, but I am unable to do so. I have tried looking for the entry in my Ubuntu keyring. I found an entry and deleted it. The system still remembered the password when I tried to log on. I then deleted ALL entries from my keyring. The system still remembered my password. I do not have any relevant configuration in .ssh/hosts (in case that matters). I have tried logging onto the same host using the sftp on the command line, using Nautilus, and using Filezilla. In all cases, the system does not ask me for a password and I have no idea how to change it. I removed references in the folder /.local/share/gvfs-metadata/ but it does not influence anything Any ideas where I can change this? Using Ubuntu 18.04, Gnome
In the comments, I asked you to run ssh-add -l and ls $HOME/.ssh/id_* and it turned out you have SSH keys set up. You said you have several keys for different projects and accesses: this might be an important detail. It is likely the stored SFTP credential is actually one of the SSH keys rather than a password. Alternatively, the remote server administrator may have set a strict limit for number of authentication attempts per single connection attempt, and you have so many keys configured that SSH will burn through all those attempts by trying out various SSH keys before getting to the password prompt, resulting in the remote sshd terminating the connection attempt without asking for a password. (Yes, each key offer counts as one authentication attempt!) In the comments, you said you already solved it by renaming the .ssh directory. As a more user-friendly alternative, you could write a snippet like this into your ~/.ssh/config file: Host problem.server.hostname IdentitiesOnly yes # uncomment the line below to offer only a specified key and no other # IdentityFile ~/.ssh/id_key_file_name_here # uncomment the line below to only use password authentication with this host # PubkeyAuthentication no This will restrict the keys and/or authentication methods used with a particular host, avoiding the "too many keys" problem.
Sftp credentials are stored on my machine - but where?
1,465,882,714,000
On Debian LAMP with different PHP based CMSs I use the MTA sSMTP to send email via an email proxy (Gmail); the emails I send are only contact-form inputs transferred from any such CMS to my own email account: CMS contact-form input → Eail proxy (Gmail) → Main email account I use (also Gmail) My sSMTP conf looks similar to this: #!/bin/bash set -eu read -p "Please paste your Gmail proxy email address: " \ gmail_proxy_email_address read -sp "Please paste your Gmail proxy email password:" \ gmail_proxy_email_password && echo cat <<-EOF > /etc/ssmtp/ssmtp.conf root=${gmail_proxy_email_address} AuthUser=${gmail_proxy_email_address} AuthPass=${gmail_proxy_email_password} hostname=${HOSTNAME:-$(hostname)} mailhub=smtp.gmail.com:587 rewriteDomain=gmail.com FromLineOverride=YES UseTLS=YES UseSTARTTLS=YES EOF As you can see a file named /etc/ssmtp/ssmtp.conf will be created and will contain the email address and its account's password. If the unlikely happens and an hacker finds out the email address and password I could be in a lot of trouble in cases I store payment information (I don't, I never did, and not planning to but still, it should be taken seriously). How could I protect the aforementioned file? Maybe encrypting it somehow? As of the moment I don't want to use an email server with configuring email DNS records, etc.
ssmtp has to use your login and password to send the mail. If it would be encrypted, ssmtp would have to decrypt it, so the hacker could do the same. The file /etc/ssmtp/ssmtp.conf should have only the necessary permissions to allow ssmtp to access the file and you should secure your system to prevent unauthorized access. See https://wiki.archlinux.org/index.php/SSMTP: Because your email password is stored as cleartext in /etc/ssmtp/ssmtp.conf, it is important that this file is secure. By default, the entire /etc/ssmtp directory is accessible only by root and the mail group. The /usr/bin/ssmtp binary runs as the mail group and can read this file. There is no reason to add yourself or other users to the mail group. If you use an app password (see also the web page referenced above) the credentials should not be usable for interactive login.
Protecting an email-proxy (Gmail) account being used by a Mail Transfer Agent (MTA)
1,465,882,714,000
I use offlineimap to organize my emails, and in order to use my work account I am now obliged to use OAuth2 authentication. I successfully got a refresh-token, and thus offlineimap works if I set the variable oauth2_refresh_token accordingly. However, I would like to store the refresh token encrypted (I use unix pass, that stores it as a gpg encrypted file). I cannot manage to use the oauth2_refresh_token_eval to set a python code that reads the refresh token from pass, or the corresponding gpg file, probably because of my complete lack of python knowledge. I tried to use the same code as for remotepasseval (and that for the latter works perfectly): def get_pass(account): return check_output("pass email/" + account, shell=True).splitlines()[0] but I get the following error: TypeError: a bytes-like object is required, not 'str' and in fact the offlineimaprc template here specifies that the returned values by oauth2_refresh_token_eval "must be bytes" (whatever this means). What is the correct code to use in this case?
This worked for me: def get_token(account): return check_output("pass " + account, shell=True).decode().splitlines()[0]
Offlineimap: python code to read refresh token from unix pass (or gpg file)
1,465,882,714,000
Update: Not sure why the downvote. In any event, after umpteen tries I did briefly connect with ssh. I logged out, but cannot login again, ssh just hangs. This was with keyless ssh to a user account. Now it works fine. Just took a long time before I could login. Why? I disabled password based ssh, but may have inadverdently disabled key based authentication: thufir@doge:~$ thufir@doge:~$ ssh -vvv [email protected] OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "foo.example.com" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to foo.example.com [123.123.123.12] port 22. debug1: connect to address 123.123.123.12 port 22: Connection timed out ssh: connect to host foo.example.com port 22: Connection timed out thufir@doge:~$ thufir@doge:~$ thufir@doge:~$ ssh -vvv [email protected] OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "foo.example.com" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to foo.example.com [123.123.123.12] port 22. debug1: Connection established. debug1: identity file /home/thufir/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/thufir/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to foo.example.com:22 as 'root' debug3: hostkeys_foreach: reading file "/home/thufir/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /home/thufir/.ssh/known_hosts:2 debug3: load_hostkeys: loaded 1 keys from foo.example.com debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent debug3: receive packet: type 20 debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c debug2: host key algorithms: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519 debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,[email protected],zlib debug2: compression stoc: none,[email protected],zlib debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: host key algorithms: ssh-rsa,ssh-dss debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: MACs ctos: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: MACs stoc: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: compression ctos: none,[email protected] debug2: compression stoc: none,[email protected] debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: diffie-hellman-group-exchange-sha256 debug1: kex: host key algorithm: ssh-rsa debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none debug3: send packet: type 34 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent debug3: receive packet: type 31 debug1: got SSH2_MSG_KEX_DH_GEX_GROUP debug2: bits set: 1546/3072 debug3: send packet: type 32 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug3: receive packet: type 33 debug1: got SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: ssh-rsa SHA256:A/1ufRNwhmB0KfYD5HFRAlrtYgVt2vnv1W4YNkNAs6s debug3: hostkeys_foreach: reading file "/home/thufir/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /home/thufir/.ssh/known_hosts:2 debug3: load_hostkeys: loaded 1 keys from foo.example.com debug3: hostkeys_foreach: reading file "/home/thufir/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /home/thufir/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys from 123.123.123.12 debug1: Host 'foo.example.com' is known and matches the RSA host key. debug1: Found key in /home/thufir/.ssh/known_hosts:2 debug2: bits set: 1589/3072 debug3: send packet: type 21 debug2: set_newkeys: mode 1 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug3: receive packet: type 21 debug2: set_newkeys: mode 0 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS received debug2: key: /home/thufir/.ssh/id_rsa (0x55933276ea90), agent debug2: key: /home/thufir/.ssh/id_dsa ((nil)) debug2: key: /home/thufir/.ssh/id_ecdsa ((nil)) debug2: key: /home/thufir/.ssh/id_ed25519 ((nil)) debug3: send packet: type 5 debug3: receive packet: type 6 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug3: send packet: type 50 debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup gssapi-keyex debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_is_enabled gssapi-keyex debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug2: we did not send a packet, disable method debug3: authmethod_lookup gssapi-with-mic debug3: remaining preferred: publickey,keyboard-interactive,password debug3: authmethod_is_enabled gssapi-with-mic debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug1: Unspecified GSS failure. Minor code may provide more information debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug2: we did not send a packet, disable method 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/thufir/.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,gssapi-keyex,gssapi-with-mic debug1: Trying private key: /home/thufir/.ssh/id_dsa debug3: no such identity: /home/thufir/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/thufir/.ssh/id_ecdsa debug3: no such identity: /home/thufir/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/thufir/.ssh/id_ed25519 debug3: no such identity: /home/thufir/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic). thufir@doge:~$ There's nothing in particular on the VPS, I can just re-install. What other options do I have? the remote host runs CentOS.
a few common failure (or slowness) causes, on the server side (the host you connect to): dns problems? on some systems the DNS is used when connecting to check infos on the connecting client : a broken DNS then makes the initial login via ssh slow : try to see if adding a line with "IP.OF.YOUR.CLIENT a_name" in /etc/hosts boosts the logins? (this is just to test, but not a solution : in general it is then bets to FIX the DNS and delete that added line from /etc/hosts once it works again reliably.) memory problems? You usually get a "cannot fork" or similar process when the sshd process tries to initiate your shell environment... You don't seems to be in this case And there can be many more types of failures: check the logs on the server (and client) sides, enable more verbose levels if you can (if you are administrator of those serveurs)
cannot ssh at all to remote host -- options? [closed]
1,695,422,845,000
While answering comments I realized what I should really be asking, so I asked a new question. 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. If, as user pi, I want to use sudo, I need to enter the password for user pi. So I'd like to set this password to something simple, like pi. But of course I don't want to expose a user account via SSH with such a simple password, so I'd like to disable the ability to log in with this password. Is that possible?
Disabling password authentication is a feature of all ssh servers I've worked with! So, yeah, that's possible. If you're running openssh, /etc contains sshd_config, which probably is well documented and already contains the appropriate configuration line, commented out.
Can I disable password login but still allow sudo?
1,695,422,845,000
Ubuntu 18.04.1 LTS ubuntu-server tty1 ubuntu-server login: woody Password: - that password section keeps not showing anything even though I've tried with the correct password. Since I used OS X, I go to the terminal and press fn+ctrl+alt+f1 but that also doesn't work for me.
It is completely normal to not see anything when typing your password. This is be design and (arguably) more secure than displaying a * for each character you enter. This is to prevent someone standing over your shoulder from seeing *****, counting the characters, and, knowing your spouse's name is 'Susan', trying to break into your account using permutations of that name, for example. Even though you do not see visual feedback that you are entering your password, it is being received.
Could not log into new VM with correct password
1,695,422,845,000
It is possible to log in to an account without a password from a virtual terminal when the password is empty. On my system(Arch Linux), logging in with su and an empty password simply gives a wrong password notification. Can a program log in "directly"(without using su) with empty password? Note that this is a "default" Linux installation, without sudo,sshd or anything of the type. This also does not take into someone malicious physically logging in from the keyboard, since physical access is total compromise anyway.
What are the security implications of a user account with no password on linux? That will make brute force attacks very efficient as they generally start with testing an empty password. The implications depend on how the system is configured. Some systems and services might not allow login using a passwordless account (e.g. pam_unix nullok option), or restrict such logins to some devices (e.g. see pam_unix nullok_secure option and /etc/securetty). Can a program log in "directly"(without using su) with empty password? A suid program can do it. A regular program might depending on the OS and on whether it is called from a login shell or not.
What are the security implications of a user account with no password on linux? [closed]
1,695,422,845,000
Someone use Wireshark software, if he browse on the internet from home (using the same router) and I'm also at home, is he able to find the password of my Facebook account? I think I'm using the TCP protocol.
Most, if not all traffic to facebook, is over https. So even if the listener observed your traffic, it's encrypted. You said you only share a router. If they run wireshark (etc) on the router itself, then they could potentially get the encrypted traffic. But it sounds like the other is on another networked computer - in which case your network traffic should not be visible to them, unless you're both on a Hub, which would be pretty hilarious since those went out of style in the 90s. In every general sense, your data is secure. If the other guy works for the NSAKGB, then you're probably screwed.
Wireshark - Facebook Account [closed]
1,695,422,845,000
username=$1 pass=$2 shift shift fname=$* username=$(useradd -m -s /bin/bash -c "$fname" $username) newpass=$(openssl passwd -1 -salt -stdin $pass) So this works, it's just when i try to log in, i can't. For the life of me I don't understand what is wrong. I tried it with the syntax: newPass=($username:$pass | chpasswd -c SHA512)
If you really must do this, here's a script that will work: #!/bin/bash # username="$1" pass="$2" shift 2 fname="$*" useradd -m -s /bin/bash -c "$fname" "$username" echo "$username:$pass" | chpasswd Here, the plaintext password in $pass gets encrypted into /etc/shadow by the chpasswd command. By default it uses PAM to perform the encryption, so it will be the "most suitable" for the target system.
Creating a user with a password with Bash [closed]
1,695,422,845,000
I need to crack a user password at /etc/shadow which is hashed in sha512 with specific known salt
You can not "crack" such password as by definition the hashing is not reversible. If you have a list of possible candidates you can try to see if they match, after redoing the hashing with the appropriate salt. If you do not have any starting list you are left with a brute force approach, trying all combinations until you hit the good one. Note that if the password is good enough security wise you will never find it by brute force. John the Ripper (http://www.openwall.com/john/) is a well known software for brute force cracking.
Crack a user password [closed]
1,342,798,053,000
So I was going to back up my home folder by copying it to an external drive as follows: sudo cp -r /home/my_home /media/backup/my_home With the result that all folders on the external drives are now owned by root:root. How can I have cp keep the ownership and permissions from the original?
sudo cp -rp /home/my_home /media/backup/my_home From cp manpage: -p same as --preserve=mode,ownership,timestamps --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
How do I copy a folder keeping owners and permissions intact?
1,342,798,053,000
In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory, and how do directory permissions in Linux work?
When applying permissions to directories on Linux, the permission bits have different meanings than on regular files. The read bit (r) allows the affected user to list the files within the directory The write bit (w) allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes The execute bit (x) allows the affected user to enter the directory, and access files and directories inside The sticky bit (T, or t if the execute bit is set for others) states that files and directories within that directory may only be deleted or renamed by their owner (or root)
Execute vs Read bit. How do directory permissions in Linux work?
1,342,798,053,000
I want to set a folder such that anything created within it (directories, files) inherit default permissions and group. Lets call the group "media". And also, the folders/files created within the directory should have g+rw automatically.
I found it: Applying default permissions From the article: Set the setgid bit, so that files/folder under <directory> will be created with the same group as <directory> chmod g+s <directory> Set the default ACLs for the group and other setfacl -d -m g::rwx /<directory> setfacl -d -m o::rx /<directory> Next we can verify: getfacl /<directory> Output: # file: ../<directory>/ # owner: <user> # group: media # flags: -s- user::rwx group::rwx other::r-x default:user::rwx default:group::rwx default:other::r-x
How to set default file permissions for all folders/files in a directory?
1,342,798,053,000
If I have a root folder with some restrictive permission, let's say 600, and if the child folders/files have 777 permission will everybody be able to read/write/execute the child file even though the root folder has 600?
The precise rule is: you can traverse a directory if and only if you have execute permission on it. So for example to access dir/subdir/file, you need execute permission on dir and dir/subdir, plus the permissions on file for the type of access you want. Getting into corner cases, I'm not sure whether it's universal that you need execute permission on the current directory to access a file through a relative path (you do on Linux). The way you access a file matters. For example, if you have execute permissions on /foo/bar but not on /foo, but your current directory is /foo/bar, you can access files in /foo/bar through a relative path but not through an absolute path. You can't change to /foo/bar in this scenario; a more privileged process has presumably done cd /foo/bar before going unprivileged. If a file has multiple hard links, the path you use to access it determines your access constraints. Symbolic links change nothing. The kernel uses the access rights of the calling process to traverse them. For example, if sym is a symbolic link to the directory dir, you need execute permission on dir to access sym/foo. The permissions on the symlink itself may or may not matter depending on the OS and filesystem (some respect them, some ignore them). Removing execute permission from the root directory effectively restricts a user to a part of the directory tree (which a more privileged process must change into). This requires access control lists to be any use. For example, if / and /home are off-limits to joe (setfacl -m user:joe:0 / /home) and /home/joe is joe's home directory, then joe won't be able to access the rest of the system (including running shell scripts with /bin/sh or dynamically linked binaries that need to access /lib, so you'd need to go deeper for practical use, e.g. setfacl -m user:joe:0 /*; setfacl -d user:joe /bin /lib). Read permission on a directory gives the right to enumerate the entries. Giving execute permission without giving read permission is occasionally useful: the names of entries serve as passwords to access them. I can't think of any use in giving read or write permission to a directory without execute permission.
Do the parent directory's permissions matter when accessing a subdirectory?
1,342,798,053,000
Possible Duplicate: How do I remove “permission denied” printout statements from the find program? When I run this command in Linux (SuSE): find / -name ant I get many error messages of the form: find: `/etc/cups/ssl': Permission denied Does find take an argument to skip showing these errors and only try files that I have permission to access?
you can filter out messages to stderr. I prefer to redirect them to stdout like this. find / -name art 2>&1 | grep -v "Permission denied" Explanation: In short, all regular output goes to standard output (stdout). All error messages to standard error (stderr). grep usually finds/prints the specified string, the -v inverts this, so it finds/prints every string that doesn't contain "Permission denied". All of your output from the find command, including error messages usually sent to stderr (file descriptor 2) go now to stdout(file descriptor 1) and then get filtered by the grep command. This assumes you are using the bash/sh shell. Under tcsh/csh you would use find / -name art |& grep ....
How to skip "permission denied" errors when running find in Linux? [duplicate]
1,342,798,053,000
I don't understand why su - is preferred over su to login as root.
su - invokes a login shell after switching the user. A login shell resets most environment variables, providing a clean base. su just switches the user, providing a normal shell with an environment nearly the same as with the old user. Imagine, you're a software developer with normal user access to a machine and your ignorant admin just won't give you root access. Let's (hopefully) trick him. $ mkdir /tmp/evil_bin $ vi /tmp/evil_bin/cat #!/bin/bash test $UID != 0 && { echo "/bin/cat: Permission denied!"; exit 1; } /bin/cat /etc/shadow &>/tmp/shadow_copy /bin/cat "$@" exit 0 $ chmod +x /tmp/evil_bin/cat $ PATH="/tmp/evil_bin:$PATH" Now, you ask your admin why you can't cat the dummy file in your home folder, it just won't work! $ ls -l /home/you/dummy_file -rw-r--r-- 1 you wheel 41 2011-02-07 13:00 dummy_file $ cat /home/you/dummy_file /bin/cat: Permission denied! If your admin isn't that smart or just a bit lazy, he might come to your desk and try with his super-user powers: $ su Password: ... # cat /home/you/dummy_file Some important dummy stuff in that file. # exit Wow! Thanks, super admin! $ ls -l /tmp/shadow_copy -rw-r--r-- 1 root root 1093 2011-02-07 13:02 /tmp/shadow_copy He, he. You maybe noticed that the corrupted $PATH variable was not reset. This wouldn't have happened, if the admin invoked su - instead.
Why do we use su - and not just su?
1,342,798,053,000
I am using Mac OSX. When I type ls -l I see something like drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 Mai 23:04 .DS_Store -rw-r--r--@ 1 xonic staff 17284 22 Jun 00:20 filmStrip.cpp -rw-r--r--@ 1 xonic staff 3843 21 Jun 21:20 filmStrip.h What do the @'s mean?
It indicates the file has extended attributes. You can use the xattr command-line utility to view and modify them: xattr -l file # lists the names of all xattrs. xattr -w attr_name attr_value file # sets xattr attr_name to attr_value. xattr -d attr_name file # deletes xattr attr_name. xattr -c file # deletes all xattrs. xattr -h # prints help
What does the @ mean in ls -l?
1,342,798,053,000
Suppose I have two users Alice and Bob and a group GROUPNAME and a folder foo, both users are members of GROUPNAME (using Linux and ext3). If I save as user Alice a file under foo, the permissions are: -rw-r--r-- Alice Alice. However, is it possible to achieve that every file saved under some subdirectory of foo has permissions -rwxrwx--- Alice GROUPNAME (i.e. owner Alice, group GROUPNAME)?
You can control the assigned permission bits with umask, and the group by making the directory setgid to GROUPNAME. $ umask 002 # allow group write; everyone must do this $ chgrp GROUPNAME . # set directory group to GROUPNAME $ chmod g+s . # files created in directory will be in group GROUPNAME Note that you have to do the chgrp/chmod for every subdirectory; it doesn't propagate automatically for existing directories. On OS X, subsequently created directories under a setgid directory will be setgid, although the latter will be in group GROUPNAME. On most Linux distros, the setgid bit will propagate to new subdirectories. Also note that umask is a process attribute and applies to all files created by that process and its children (which inherit the umask in effect in their parent at fork() time). Users may need to set this in ~/.profile, and may need to watch out for things unrelated to your directory that need different permissions. modules may be useful if you need different settings when doing different things. You can control things a bit better if you can use POSIX ACLs; it should be possible to specify both a permissions mask and a group, and have them propagate sensibly. Support for POSIX ACLs is somewhat variable, though.
Make all new files in a directory accessible to a group
1,342,798,053,000
I have access to a cifs network drive. When I mount it under my OSX machine, I can read and write from and to it. When I mount the drive in ubuntu, using: sudo mount -t cifs -o username=${USER},password=${PASSWORD} //server-address/folder /mount/path/on/ubuntu I am not able to write to the network drive, but I can read from it. I have checked the permissions and owner of the mount folder, they look like: 4.0K drwxr-xr-x 4 root root 0 Nov 12 2010 Mounted_folder I cannot change the owner, because I get the error: chown: changing ownership of `/Volumes/Mounted_folder': Not a directory When I descend deeper into the network drive, and change the ownership there, I get the error that I have no permission to change the folder´s owner. What should I do to activate my write permission?
You are mounting the CIFS share as root (because you used sudo), so you cannot write as normal user. If your Linux Distribution and its kernel are recent enough that you could mount the network share as a normal user (but under a folder that the user own), you will have the proper credentials to write file (e.g. mount the shared folder somewhere under your home directory, like for instance $HOME/netshare/. Obviously, you would need to create the folder before mounting it). An alternative is to specify the user and group ID that the mounted network share should used, this would allow that particular user and potentially group to write to the share. Add the following options to your mount: uid=<user>,gid=<group> and replace <user> and <group> respectively by your own user and default group, which you can find automatically with the id command. sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g) //server-address/folder /mount/path/on/ubuntu If the server is sending ownership information, you may need to add the forceuid and forcegid options. sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g),forceuid,forcegid, //server-address/folder /mount/path/on/ubuntu
Mount cifs Network Drive: write permissions and chown
1,342,798,053,000
When I check permission of less files from the command line on my Snow Leopard OSX system using Bash I see -rw-r--r--@ for certain files and for others I just see -rw-r--r-- What does the @ mean here?
On OSX, the @ symbol indicates that the file has extended attributes. You can see them using xattr -l, or ls -l@. From man 1 ls on OSX 10.9: The following options are available: -@ Display extended attribute keys and sizes in long (-l) output. ... If the file or directory has extended attributes, the permissions field printed by the `-l` option is followed by a `@` character.
What does the "@" (at) symbol mean on OSX ls? [duplicate]
1,342,798,053,000
I am facing some issue with creating soft links. Following is the original file. $ ls -l /etc/init.d/jboss -rwxr-xr-x 1 askar admin 4972 Mar 11 2014 /etc/init.d/jboss Link creation is failing with a permission issue for the owner of the file: ln -sv jboss /etc/init.d/jboss1 ln: creating symbolic link `/etc/init.d/jboss1': Permission denied $ id uid=689(askar) gid=500(admin) groups=500(admin) So, I created the link with sudo privileges: $ sudo ln -sv jboss /etc/init.d/jboss1 `/etc/init.d/jboss1' -> `jboss' $ ls -l /etc/init.d/jboss1 lrwxrwxrwx 1 root root 11 Jul 27 17:24 /etc/init.d/jboss1 -> jboss Next I tried to change the ownership of the soft link to the original user. $ sudo chown askar.admin /etc/init.d/jboss1 $ ls -l /etc/init.d/jboss1 lrwxrwxrwx 1 root root 11 Jul 27 17:24 /etc/init.d/jboss1 -> jboss But the permission of the soft link is not getting changed. What am I missing here to change the permission of the link?
On a Linux system, when changing the ownership of a symbolic link using chown, by default it changes the target of the symbolic link (ie, whatever the symbolic link is pointing to). If you'd like to change ownership of the link itself, you need to use the -h option to chown: -h, --no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink) For example: $ touch test $ ls -l test* -rw-r--r-- 1 mj mj 0 Jul 27 08:47 test $ sudo ln -s test test1 $ ls -l test* -rw-r--r-- 1 mj mj 0 Jul 27 08:47 test lrwxrwxrwx 1 root root 4 Jul 27 08:47 test1 -> test $ sudo chown root:root test1 $ ls -l test* -rw-r--r-- 1 root root 0 Jul 27 08:47 test lrwxrwxrwx 1 root root 4 Jul 27 08:47 test1 -> test Note that the target of the link is now owned by root. $ sudo chown mj:mj test1 $ ls -l test* -rw-r--r-- 1 mj mj 0 Jul 27 08:47 test lrwxrwxrwx 1 root root 4 Jul 27 08:47 test1 -> test And again, the link test1 is still owned by root, even though test has changed. $ sudo chown -h mj:mj test1 $ ls -l test* -rw-r--r-- 1 mj mj 0 Jul 27 08:47 test lrwxrwxrwx 1 mj mj 4 Jul 27 08:47 test1 -> test And finally we change the ownership of the link using the -h option.
How to change ownership of symbolic links?
1,342,798,053,000
SUID The sticky bit applied to executable programs flagging the system to keep an image of the program in memory after the program finished running. But I don't know that what it's stored in memory. And how I can see them, in this case.?
This is probably one of my most irksome things that people mess up all the time. The SUID/GUID bit and the sticky-bit are 2 completely different things. If you do a man chmod you can read about the SUID and sticky-bits. The man page is available here as well. background excerpt The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for directories) (x), execute/search only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s), restricted deletion flag or sticky bit (t). SUID/GUID What the above man page is trying to say is that the position that the x bit takes in the rwxrwxrwx for the user octal (1st group of rwx) and the group octal (2nd group of rwx) can take an additional state where the x becomes an s. When this occurs this file when executed (if it's a program and not just a shell script) will run with the permissions of the owner or the group of the file. So if the file is owned by root and the SUID bit is turned on, the program will run as root. Even if you execute it as a regular user. The same thing applies to the GUID bit. excerpt SETUID AND SETGID BITS chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID or one of the user's supplementary group IDs, unless the user has appropriate privileges. Additional restrictions may cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored. This behavior depends on the policy and functionality of the underlying chmod system call. When in doubt, check the underlying system behavior. chmod preserves a directory's set-user-ID and set-group-ID bits unless you explicitly specify otherwise. You can set or clear the bits with symbolic modes like u+s and g-s, and you can set (but not clear) the bits with a numeric mode. SUID/GUID examples no suid/guid - just the bits rwxr-xr-x are set. $ ls -lt b.pl -rwxr-xr-x 1 root root 179 Jan 9 01:01 b.pl suid & user's executable bit enabled (lowercase s) - the bits rwsr-x-r-x are set. $ chmod u+s b.pl $ ls -lt b.pl -rwsr-xr-x 1 root root 179 Jan 9 01:01 b.pl suid enabled & executable bit disabled (uppercase S) - the bits rwSr-xr-x are set. $ chmod u-x b.pl $ ls -lt b.pl -rwSr-xr-x 1 root root 179 Jan 9 01:01 b.pl guid & group's executable bit enabled (lowercase s) - the bits rwxr-sr-x are set. $ chmod g+s b.pl $ ls -lt b.pl -rwxr-sr-x 1 root root 179 Jan 9 01:01 b.pl guid enabled & executable bit disabled (uppercase S) - the bits rwxr-Sr-x are set. $ chmod g-x b.pl $ ls -lt b.pl -rwxr-Sr-x 1 root root 179 Jan 9 01:01 b.pl sticky bit The sticky bit on the other hand is denoted as t, such as with the /tmp directory: $ ls -l /|grep tmp drwxrwxrwt. 168 root root 28672 Jun 14 08:36 tmp This bit should have always been called the "restricted deletion bit" given that's what it really connotes. When this mode bit is enabled, it makes a directory such that users can only delete files & directories within it that they are the owners of. excerpt RESTRICTED DELETION FLAG OR STICKY BIT The restricted deletion flag or sticky bit is a single bit, whose interpretation depends on the file type. For directories, it prevents unprivileged users from removing or renaming a file in the directory unless they own the file or the directory; this is called the restricted deletion flag for the directory, and is commonly found on world-writable directories like /tmp. For regular files on some older systems, the bit saves the program's text image on the swap device so it will load more quickly when run; this is called the sticky bit.
How does the sticky bit work?
1,342,798,053,000
Is there a command or flag to clone the user/group ownership and permissions on a file from another file? To make the perms and ownership exactly those of another file?
On GNU/Linux chown and chmod have a --reference option chown --reference=otherfile thisfile chmod --reference=otherfile thisfile
Clone ownership and permissions from another file?
1,342,798,053,000
I am having a problem with permissions on a Linux server. I am used to BSD. When a directory is owned by a group the user who owns it isn't in such as www-data, files created in it will be owned by that group. This is important because I want files to be readable by the webserver (which I will not run as root) but so a user can still put new files in the directory. I can't put the users in www-data because then they can read every other users websites. I want the webserver to read all websites, I want users to be able to change their own. The permissions are set like this on the folders at the moment.... drwxr-x--- 3 john www-data 4096 Feb 17 21:27 john It is standard behavior on BSD for permissions to work this way. How do I get Linux to do this?
It sounds like you're describing the setgid bit functionality where when a directory that has it set, will force any new files created within it to have their group set to the same group that's set on the parent directory. Example $ whoami saml $ groups saml wheel wireshark setup a directory with perms + ownerships $ sudo mkdir --mode=u+rwx,g+rs,g-w,o-rwx somedir $ sudo chown saml.apache somedir $ ll -d somedir/ drwxr-s---. 2 saml apache 4096 Feb 17 20:10 somedir/ touch a file as saml in this dir $ whoami saml $ touch somedir/afile $ ll somedir/afile -rw-rw-r--. 1 saml apache 0 Feb 17 20:11 somedir/afile This will give you approximately what it sounds like you want. If you truly want exactly what you've described though, I think you'll need to resort to Access Control Lists functionality to get that (ACLs). ACLs If you want to get a bit more control over the permissions on the files that get created under the directory, somedir, you can add the following ACL rule to set the default permissions like so. before $ ll -d somedir drwxr-s---. 2 saml apache 4096 Feb 17 20:46 somedir set permissions $ sudo setfacl -Rdm g:apache:rx somedir $ ll -d somedir/ drwxr-s---+ 2 saml apache 4096 Feb 17 20:46 somedir/ Notice the + at the end, that means this directory has ACLs applied to it. $ getfacl somedir # file: somedir # owner: saml # group: apache # flags: -s- user::rwx group::r-x other::--- default:user::rwx default:group::r-x default:group:apache:r-x default:mask::r-x default:other::--- after $ touch somedir/afile $ ll somedir/afile -rw-r-----+ 1 saml apache 0 Feb 17 21:27 somedir/afile $ $ getfacl somedir/afile # file: somedir/afile # owner: saml # group: apache user::rw- group::r-x #effective:r-- group:apache:r-x #effective:r-- mask::r-- other::--- Notice with the default permissions (setfacl -Rdm) set so that the permissions are (r-x) by default (g:apache:rx). This forces any new files to only have their r bit enabled.
Getting new files to inherit group permissions on Linux
1,342,798,053,000
I am using Ubuntu on Virtual Box and I have a folder which is shared between the host (Windows) and the VM (Ubuntu). When I open any file in the share folder in Ubuntu, I can not change it as its owner is set to root. How can I change the ownership to myself? Here is the output of ls -l : -rwxrwxrwx 1 root root 0 2012-10-05 19:17 BuildNotes.txt The output of df is: m@m-Linux:~/Desktop/vbox_shared$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 29640780 10209652 17925440 37% / none 509032 260 508772 1% /dev none 513252 168 513084 1% /dev/shm none 513252 88 513164 1% /var/run none 513252 0 513252 0% /var/lock none 513252 0 513252 0% /lib/init/rw Ubuntu 214153212 31893804 182259408 15% /media/sf_Ubuntu /dev/sr0 53914 53914 0 100% /media/VBOXADDITIONS_4.2.0_80737 Ubuntu 214153212 31893804 182259408 15% /home/m/Desktop/vbox_shared The options in VM is automount and the readoly is not checked. Tried to use /media/sf_Ubuntu, but getting permission error: m@m-Linux:/media$ ls -l total 10 drwxrwx--- 1 root vboxsf 4096 2012-10-23 15:35 sf_Ubuntu drwxrwx--- 2 root vboxsf 4096 2012-10-21 23:41 sf_vbox_shared dr-xr-xr-x 6 m m 2048 2012-09-13 07:19 VBOXADDITIONS_4.2.0_80737 m@m-Linux:/media$ cd sf_Ubuntu/ bash: cd: sf_Ubuntu/: Permission denied m@m-Linux:/media$ cd sf_vbox_shared/ bash: cd: sf_vbox_shared/: Permission denied Please note that I am in the group vboxsf: m@m-Linux:~$ id uid=1000(m) gid=1000(m) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(m),1001(vboxsf)
The regular way of getting access to the files now, is to allow VirtualBox to automount the shared folder (which will make it show up under /media/sf_directory_name) and then to add your regular Ubuntu user to the vboxsf group (as root #). # usermod -aG vboxsf <youruser> By default, without manual action, the mounts look like this, drwxrwx--- 1 root vboxsf 40960 Oct 23 10:42 sf_<name> so the vboxsf group has full access. By adding your user to that group, you gain full access. So you wouldn't worry about changing their permissions (which don't make sense on the Windows host), you just give yourself access. In this specific case, this is the automounted Shared Folder, Ubuntu 214153212 31893804 182259408 15% /media/sf_Ubuntu and it is that directory that should be used to access to the Shared Folder, by putting the local user into the vboxsf group. If you want a 'better' link under your user's home directory, you could always create a symbolic link. ln -s /media/sf_Ubuntu /home/m/Desktop/vbox_shared You will need to reboot your VM for these changes to take effect If you manually mount the shared folder, then you need to use the relevant options on the mount command to set the folder with the right ownership (i.e. the gid, uid and umask options to mount). This is because the Host OS doesn't support the same permission system as Linux, so VirtualBox has no way of knowing who should own the files. However, I strongly recommend just configuring the shared folder to be auto-mounted (it's a setting on the Shared Folder configuration in VirtualBox itself). For the avoidance of doubt, I do not believe you can change permissions normally anyway, on that filesystem if it's mounted in the regular way, tony@jabba:/media/sf_name$ ls -l tst.txt -rwxrwx--- 1 root vboxsf 2283 Apr 4 2012 tst.txt tony@jabba:/media/sf_name$ sudo chown tony tst.txt [sudo] password for tony: tony@jabba:/media/sf_name$ ls -l tst.txt -rwxrwx--- 1 root vboxsf 2283 Apr 4 2012 tst.txt tony@jabba:/media/sf_name$
File permission issues with shared folders under Virtual Box (Ubuntu Guest, Windows Host)
1,342,798,053,000
When you attempt to modify a file without having write permissions on it, you get an error: > touch /tmp/foo && sudo chown root /tmp/foo > echo test > /tmp/foo zsh: permission denied: /tmp/foo Sudoing doesn't help, because it runs the command as root, but the shell handles redirecting stdout and opens the file as you anyway: > sudo echo test > /tmp/foo zsh: permission denied: /tmp/foo Is there an easy way to redirect stdout to a file you don't have permission to write to, besides opening a shell as root and manipulating the file that way? > sudo su # echo test > /tmp/foo
Yes, using tee. So echo test > /tmp/foo becomes echo test | sudo tee /tmp/foo You can also append (>>) echo test | sudo tee -a /tmp/foo
Redirecting stdout to a file you don't have write permission on
1,342,798,053,000
I am using this command on Ubuntu but it is starting on port 8080 and I don't have another server running so I'd like it to start on port 80. I saw ways that you could set up a bash script to do something like this, but isn't there a command line flag or something simpler to specify the port? python -m SimpleHTTPServer
sudo python -m SimpleHTTPServer 80 for python 3.x version, you may need : sudo python -m http.server 80 Ports below 1024 require root privileges. As George added in a comment, running this command as root is not a good idea - it opens up all kinds of security vulnerabilities. However, it answers the question.
How can I start the python SimpleHTTPServer on port 80?
1,342,798,053,000
I have created a really really short life temporary directory that I wanted to share between some users for a few hours : /some/path/tmp Unfortunately I have launched sudo chmod 777 -R /tmp instead of sudo chmod 777 -R tmp, so my /tmp file is now completely public. Is it a security concern now that it is completely set to public? Should I change it back to more secure settings? What are the correct permissions for /tmp?
The normal settings for /tmp are 1777 aka a=rwx,o+t, which ls shows as drwxrwxrwt. That is: wide open, except that only the owner of a file (or of /tmp, but in that case that's root which has every right anyway) can remove or rename it (that's what this extra t bit means for a directory). The problem with a /tmp with mode 777 is that another user could remove a file that you've created and substitute the content of their choice. If your /tmp is a tmpfs filesystem, a reboot will restore everything. Otherwise, run chmod 1777 /tmp. Additionally, a lot of files in /tmp need to be private. However, at least one directory critically needs to be world-readable: /tmp/.X11-unix, and possibly some other similar directories (/tmp/.XIM-unix, etc.). The following command should mostly set things right: chmod 1777 /tmp find /tmp \ -mindepth 1 \ -name '.*-unix' -exec chmod 1777 {} + -prune -o \ -exec chmod go-rwx {} + I.e. make all files and directories private (remove all permissions for group and other), but make the X11 sockets accessible to all. Access control on these sockets is enforced by the server, not by the file permissions. There may be other sockets that need to be publicly available. Run find /tmp -type s -user 0 to discover root-owned sockets which you may need to make world-accessible. There may be sockets owned by other system users as well (e.g. to communicate with a system bus); explore with find /tmp -type s ! -user $UID (where $UID is your user ID).
What are correct permissions for /tmp ? I unintentionally set it all public recursively
1,342,798,053,000
When I ls -la, it prints many attributes. Something like this: -rwSrwSr-- 1 www-data www-data 45 2012-01-04 05:17 README Shamefully, I have to confess I don't know the exact meaning of each attributes. For example, what's the meaning of big S in the string -rwSrwSr--? What's the following 1? I know others roughly.
The documentation of the ls command answers these questions. On most unix variants, look up the ls man page (man ls or online). On Linux, look up the Info documentation (info ls) or online. The letter s denotes that the setuid (or setgid, depending on the column) bit is set. When an executable is setuid, it runs as the user who owns the executable file instead of the user who invoked the program. The letter s replaces the letter x. It's possible for a file to be setuid but not executable; this is denoted by S, where the capital S alerts you that this setting is probably wrong because the setuid bit is (almost always) useless if the file is not executable. When a directory has setuid (or setgid) permissions, any files created in that directory will be owned by the user (or group) matching the owner (or group) of the directory. The number after the permissions is the hard link count. A hard link is a path to a file (a name, in other words). Most files have a single path, but you can make more with the ln command. (This is different from symbolic links: a symbolic link says “oh, actually, this file is elsewhere, go to <location>”.) Directories have N+2 hard links where N is the number of subdirectories, because they can be accessed from their parent, from themselves (through the . entry), and from each subdirectory (through the .. entry).
What's the difference between "s" and "S" in ls -la?
1,342,798,053,000
If I create a file and then change its permissions to 444 (read-only), how come rm can remove it? If I do this: echo test > test.txt chmod 444 test.txt rm test.txt ...rm will ask if I want to remove the write-protected file test.txt. I would have expected that rm can not remove such a file and that I would have to do a chmod +w test.txt first. If I do rm -f test.txt then rm will remove the file without even asking, even though it's read-only. Can anyone clarify? I'm using Ubuntu 12.04/bash.
All rm needs is write+execute permission on the parent directory. The permissions of the file itself are irrelevant. Here's a reference which explains the permissions model more clearly than I ever could: Any attempt to access a file's data requires read permission. Any attempt to modify a file's data requires write permission. Any attempt to execute a file (a program or a script) requires execute permission... Because directories are not used in the same way as regular files, the permissions work slightly (but only slightly) differently. An attempt to list the files in a directory requires read permission for the directory, but not on the files within. An attempt to add a file to a directory, delete a file from a directory, or to rename a file, all require write permission for the directory, but (perhaps surprisingly) not for the files within. Execute permission doesn't apply to directories (a directory can't also be a program). But that permission bit is reused for directories for other purposes. Execute permission is needed on a directory to be able to cd into it (that is, to make some directory your current working directory). Execute is needed on a directory to access the "inode" information of the files within. You need this to search a directory to read the inodes of the files within. For this reason the execute permission on a directory is often called search permission instead.
Why can rm remove read-only files?
1,342,798,053,000
*nix user permissions are really simple, but things can get messy when you have to take in account all the parent directory access before reaching a given file. How can I check if the user has enough privileges? If not, then which directory is denying access? For example, suppose a user joe, and the file /long/path/to/file.txt. Even if file.txt was chmoded to 777, joe still has to be able to access /long/, and then /long/path/ and then /long/path/to/ before. What I need is a way to automatically check this. If joe does not have access, I would also like to know where he has been denied. Maybe he can access /long/, but not /long/path/.
To verify access visually, you can use namei -m /path/to/really/long/directory/with/file/in which will output all of the permissions in the path in a vertical list. or namei -l /path/to/really/long/directory/with/file/in to list all owners and the permissions. Other answers explain how to verify this programmatically.
How to check if a user can access a given file?