I need to use sudo for some things, but I always get:
Password:
Sorry, try again.
Password:
sudo: 1 incorrect password attempt
I do not know why, the password is certainly correct, and whenever I am prompted to login as admin by other pieces of software with a GUI, everything works fine. It's only in the terminal that my pw is always rejected. Do I maybe somehow have to tell the system what the username of my admin account is, or anything like this?
Try
read a;echo $a
Need to check that password is actually written as typed.
Root might not have the right permission to connect to database based on that hostname or password .
Try this instead with user :
mysql -h your_host_name -p
Then put your password.
Related
I am new to ansible and having spent a long time searching I feel as though I am missing something which should be obvious.
Problem
After installing MySql8 using ansible on a Ubuntu 20.04 server I can't do anything else MySql related because the password for the MySql "root" user is set to something random and saved into the error logs. The only solution I have found to this is to retrieve the password and change it. However, this would only work once. Running the same playbook again later will cause an error since the password will already have been changed.
I have a similar issue when it comes to creating a user identified by a MySQL native password. I have found solutions which do this by first creating a user, then using a shell command to convert the user to be identified by a native password. But I don't really want that to happen every time the playbook is run. What I want is the user to be created only if it doesn't exist already.
If I were doing this manually, I would either log into MySql using
sudo mysql
or else set the root password using the mysql_secure_installation script.
Questions
Is there a way to set the root MySQL account password from ansible
without knowing the current password by using the sudo password like
above?
Is it possible to create a user identified by a native password
without using shell commands so that the user only gets created if
it doesn't already exist?
This seems to be an issue with mysql8.0
My solution at the time was below steps
Get temp password for root from
sudo grep "temporary password" /var/log/mysqld.log|cut -d ' ' -f 11
Update root password (Possibly use mysql_user module)
"sudo mysqladmin -u root password '{{ new_mysql_root_password }}' -p'{{ password_from_1 }}'"
I did this with 2 sudo commands using shell module but the ideal way would be i think \
do 1 using shell module
do a connection check on mysql using 1 and register it in a variable root_check
do 2 only when root_check does not throw error.
In my case, I ignored the error if it occurs at 2 if the password is changed the first time.
I am sure there is a better solution.
I was trying to change my windows password via command:
net user Adminstrator newpassword
However, I accidentally did this
net user Administrator "newpassword"
There is no special character in the password
Now I am not able to logon my Administrator account via either newpassword or "newpassword"
Please help.
Thank you.
Best regards,
Apparently it is an issue for Windows password change command, that you cannot put double quotes in the password, and if you did, the command will be executed successfully but nobody knows what the password is.
I resolved this issue via resetting admin password to default following the instruction at:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Config.html
I was lucky I am having this issue with AWS EC2 instance, otherwise I won't be able to resolve like that.
It happens when using escape sequence in command prompt
Run the following command in command prompt with administrator privilege
echo EnteredPassword >> C:\ActualPassword.txt
EnteredPassword is the password that you entered in the command prompt
And your actual password will be available in C:\ActualPassword.txt
Was trying to figure out how to execute a sudo command with the password as a parameter.
echo mypassword | sudo -S command
was using this reference Use sudo with password as parameter
However, on OS X it keeps say "sudo: incorrect password attempt" however that passwords is correct.
what am i doing wrong?
As pointed out in the comments already, what you're doing is a very bad idea because it leaves the password of an account laying around. Instead, if you need to run a specific command with sudo from a script, you could -- and you should -- define that single command for one specific user in such a way that its execution is allowed without having to type in the password.
So, you should edit /etc/sudoers to include an entry for your specific user for that one, single, specific command with the tag NOPASSWD:
youruser yourhostname = (root) NOPASSWD: /some/path/your/command
Or if you really don't feel like typing in the hostname of your computer, then go for:
youruser ALL = (root) NOPASSWD: /some/path/your/command
That way you will possibly leak the ability of executing that one, single command as root instead of leaking your password and with it the possibility of running any commands as root.
I'm working on a script in which I need to change the user, i have sudo access, i tried something like below but without success.
echo $passwd | sudo -S su - oracle
I even tried installed ssshpass but no success with that either. Is that even possible or do I need to install something else to make this work?
Any idea
If you will run your script with root account, you can just
message="The cake is a lie"
su username -c 'echo $message'
If you will run your script with another user you have two ways to do that,
1) Configuring pam like bellow so when you run su user2 -c 'command' logged with user1, linux will not ask for password.
Add the following lines right below the pam_rootok.so line in your /etc/pam.d/su:
auth [success=ignore default=1] pam_succeed_if.so user = user2
auth sufficient pam_succeed_if.so use_uid user = user1
The first line makes sure the target user is user2. If it is, the next line will take control and succeed authorization if the calling user is user1.
If the target user is something else, the second line will be ignored and the usual authentication steps will be performed.
2) Write your script using expect as here
I'm trying to write a simple script to mysqldump some dbs. I'm getting stuck on the password prompt though.
I'd like to just have a config file that contains all the db creds, then the script can use those to connect to the db.
Problem is a command such as:
system('mysqldump -u username -p')
then prompts for
Enter password:
even when I do something like:
system('mysqldump -u username -p some_password')
I still get prompted for the password...
I don't do a whole lot of scripting in Ruby so I'm at a loss as to how my script can automatically enter this info so the user running the script doesn't have to.
If you already know the password why aren't you passing it to the command?
system('mysqldump -u username --password=mypassword')
you need to delete space after -p
system('mysqldump -uusername -psome_password')
or without password just
system('mysqldump -uusername')
or
system('mysqldump -uusername --password=')
you could always check the application that uses the database for the password, check the config file file for the connection string. Failing that change the password in the database.