Missing sudo access in Google Compute Engine - google-compute-engine

In Google compute engine I do not have sudo ability on my VM.
According to the documentation and other threads on this topic, it should automatically be created when I SSH in from the Google Console. It worked this way for a week or two and now prompts for a password (I also rebuilt a vm that did this same thing a couple of weeks ago).
I have tried letting my keys expire, opening and closing a new session, and external ssh and they all display the same problem.
Here is a screenshot from a new browser instance:

You can try using “sudo -s” command from any user to directly switch to root and use sudo access. Also root password can be changed by using “passwd root” command after sudo access have been got.
That being said, the screen that you are getting is the lecture that is set to be displayed every time sudo is used. This can be changed in /etc/sudoers file by setting Defaults lecture=once as explained in this article. If the lecture is set to once, it will force the sudo command to show the prompt you are getting for the first time only.

Related

How can I run brew as root?

I know this is a frequently asked question, but I am really struggling.
I have recently tried to install MySQL with Homebrew on my Mac OS El-Capitan. However, I have encountered some problems with it and I want to reinstall it. Yet whenever I try doing that it gives me:
Error: Permission denied # rb_sysopen - /usr/local/var/homebrew/locks/mysql.formula.lock
I tried to bypass this error by simply sorting the named files out manually in the root account, but there were way too many files.
So I tried uninstalling it with root, but it gave me this error:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
I looked at many articles, including this link! Many of them suggested that I chown the /usr/local folder directly to my own user account with root, so I can run brew without any permission problems, but it is too dangerous.
I tried to run:
sudo chown root /usr/local/bin/brew
But this did not work as well.
Is there any ways I can bypass this error, and run brew as root?
Many of them suggested that I chown the /usr/local folder directly to my own user account with root, so I can run brew without any permission problems, but it is too dangerous.
chowning all of /usr/local/ is probably a bad idea because it's not entirely under Homebrew's control. But just /usr/local/var/homebrew/locks/mysql.formula.lock should be ok.
chown $USER /usr/local/var/homebrew/locks/mysql.formula.lock
And follow the advice of brew doctor.
tried to run: sudo chown root /usr/local/bin/brew But this did not work as well.
All this accomplished was to make the file /usr/local/bin/brew owned by root. It doesn't make it run as root. You should change it back to being owned by your user else you won't be able to upgrade brew.
To make it run as root you'd use setuid. Do not do this. It's inherently dangerous, and doubly so with your current understanding of permissions. Nothing personal, permissions take a while to get used to and appreciate.
Homebrew does not run as root to limit the damage possible by a malicious package or a simple mistake. By running as your user it can only damage what is accessible to your user. This walls off important things like system files. This is the purpose of the Unix permission system: to limit how much damage is possible. If you run brew as root all bets are off.
Furthermore, if /usr/local/var/homebrew/locks/mysql.formula.lock is owned by root that means MySQL ran as root. If you run MySQL as root and it is compromised your whole system is compromised. If you run MySQL as your user or a special limited mysql user, only your user files or mysql's own files can be compromised. Run it as proscribed by homebrew.
It's very much worth it to learn to run with as few permissions as possible.
Using brew as root is a bad idea due security reasons. Instead you can change the brew file ownership to the current logged in user. Type this single command:
sudo chown $USER /usr/local/bin/brew
i thought i would chime in to this conversation since it's one of the top hits on google still
To make it run as root you'd use setuid
i played with this today, this does not work since brew is a bash script, not an executable
One option that you have is to sudo touch /.dockerenv on linux: https://github.com/Homebrew/brew/blob/4eaaa867de30a1e09bfbf303f46493826dc746e7/Library/Homebrew/brew.sh#L182
You can also do this on macOS but it requires unsealing the root volume, which is considerably more work than what I was going to undertake today
My fix was to add a second test just like this one that whitelists brew info as a not-harmful command directly into brew.sh
i plan to submit this as an upstream patch

How do I retrieve Google SDK passphrase

Following this post, I'm trying to transfer code from my local machine to the compute engine but I forgot my passphrase.
Can someone tell me how to retrieve it.
I've searched around for solutions but found nothing.
Remove your old keys and try again, that is
rm ~/.ssh/google_compute_engine*
and then
gcloud compute ssh my_vm_name --zone zone_vm_is_in
this below works as stated by #cherba
rm ~/.ssh/google_compute_engine*
after using this command you can then reset the password to the ssh passphrase or you can simply hit enter to leave no password. i am supplying this answer because if you use the command and then attempt to ssh into an instance it takes a few seconds for the keys to propagate. i wanted to add this as a comment but didn't have enough reputation points on stack overflow.

MySQL won't configure, incorrect root password?

So i've installed MySQL server 5.6, and it just will not let me in as it keeps telling me i've got the root password wrong on the installer.
I may or may not have used another MySQL server before, but have long since deleted it and set a new root password upon installing this new server.
Since it wasn't letting me in, i decided to see if there was another way to find out my password (which there isn't) or change it (which there is) but this hasn't worked either.
This is the document i was using.
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
I have changed my password multiple times now, it's accepted it according to the command prompt, and yet it still won't let me use SQL server...
Oh and i am on the administrator's account. How do i find out, or fix the root password permanently?
Okay i've finally figured out how to solve this (and in turn get it to install fully!).
What i did was delete everything from my system relating to MySQL, uninstall it and then re-download the installer. When installing i created a new file location and made MySQL install under C:\MySQL (a new folder i made), rather than let it install into C:\Program Files... and this seemed to make it install immediately, and meant that it couldn't find (if they were still there) any previously made root passwords.
The key to what it says in that link is to run it as administrator in the Windows sense. Otherwise it all appears to work but it reverts itself when you exit.
I just had this same issue. If you go into the installer and remove MYSQL Server and re-install, it will allow you to set the root password again and continue with your configurations.

Setting up new instance of MySQL what is Current Root Password?

I am new to MySQL and am setting up a new instance of MySQL using the Windows Installer and am being prompted for two passwords.
The Current Root Password and the MySQL Root Password.
Is there a standard Current Root Password for new installations?
What is the difference between the two passwords.
If you don't remember your current root password and want to install new instance of MySQL and you have applied other ways like "-init-file.txt", but still failed.
There is another solution which worked for me. Uninstalling MySQL from control panel didn't remove all files, it left some references in the system.
To delete MySQL files completely, open the folder path C:\Users\your pc name\AppData\Roaming and delete the MySQL folder.
Then remove one more reference which is in C:\ProgramData\MySQL, if not visible check your folder view options and uncheck "Don't show hidden files".
The last reference of MySQL exists in our system services:
Type "Services" in the search box of the taskbar. Find services related to MySQL and note them down. I have two in my case(MySQLRouter and MYSQL80).
Open the command prompt with administrator and type:
sc delete "ServiceName",
In my case:
sc delete MySQL80
sc delete MySQLRouter
Ensure all services related to MySQL are removed by using the above command. Restart your computer and install your MySQL instance with a new configuration.
The standard password for user root is simply: password
Each user had its own password. So a password must belong to a user. So the only difference of password are just what they contain.
root is AFAIK the only user created upon installation. Did you create a new user after installation?
issue:- new mysql installation steps asks for current root password when it ideally should be prompting set new password option.
solution :-Issue could be due to existence of a previous unsuccessful mysql installation, leaving behind contents even after uninstalling.(at c:mysql,c:/ program files/mysql,c:/program data/mysql )
In my case they required manual deletion;after which new installation of mysql went on smooth .
(had to msconfig too, to handle unending windows hanging sometime during the process.)
The community wiki has an excellent guide on the steps that one needs to follow.
Please note that uninstalling MySQL from the installer gives the option to remove all data as well, which by default is unselected.
Check the box and then uninstall MySQL.
After that, follow the guidelines in the community wiki.
Uninstall mysql all setup fully
Delete all files related to MySQL
From program files, program files x86:
C>username>appdata_>Roaming>mysql
After that install mysql
Try switching to root user using su or sudo -i, if possible, then use password as password.

Accessing mysql via terminal

A while back I installed xampp and could not get it to run because the ports were already being used. Someone recommended that I type .. I believe it was: kill all, into the terminal to, I guess, kill the conflicting connections. This worked and I was able to access phpMyAdmin, but then I started having the problem again so i switched to MAMP. Now I can not access MySQL through the terminal. This is what I type in and this is what I get:
Macintosh:~ scottmcpherson$ mysql -u root --password=This_is_where_I_typed_my_pw
-bash: mysql: command not found
Macintosh:~ scottmcpherson$
I can, however access my database through phpMyAdmin. But the tutorials I'm following only show you how to create a database through the terminal plus I would really like to learn how to do it both ways. So, I'm thinking that the killall command screwed something up, or the other command that someone recommended a while back- which I can't remember.
You need to adjust your PATH environment variable. Details are here: http://www.metaltoad.com/blog/getting-command-line-access-php-and-mysql-running-mamp-osx
In short, open (or create) a .profile file in your home directory, and add this line:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH
Paths may need to be adjusted depending on the location of your MAMP install.