Setting root password in GCloud VM not working - google-cloud-platform

I am trying to authenticate as sudo in a linux Google Cloud VM. I know there are several similar questions, but none have solved my problem. Here's what I've tried:
Setting a password using sudo passwd, as in this answer.
Giving myself 'Compute Admin' permissions in IAM, and then running sudo passwd, as in this answer.
Running sudo invoke-rc.d procps start, as in this answer.
Running sudo passwd in the cloud shell terminal, successfully setting a password there, restarting and SSHing into my VM, and then trying to either set a password or authenticate as sudo
For all these, I am connecting using GCloud's SSH in browser. Every time, I just get prompted for the sudo password, and nothing I type in works. In case it matters, my google cloud account is associated with an institutional (university) google account.
I'm at a loss here. Any suggestions are much appreciated!

By default password based authentication and root login is disabled in GCP vms, so if you are trying to do password based ssh first you need to enable it follow this documentation for enabling password based access but it is not suggested to enable password based authentication as it makes your environment vulnerable. As you are saying your terminal is getting stuck have you checked the resource utilisations of cpu and memory.

Related

2FA is not working with Ubuntu AWS instance

I worked on setting up 2FA while doing ssh in EC2 instance. But after the setup instance is still not asking for 2FA code and directly logs my user i.e. ubuntu into the server.
I did following steps to setup 2FA:
Install Google Authenticator PAM module.
sudo apt install libpam-google-authenticator
Add auth required pam_google_authenticator.so to /etc/pam.d/sshd
Restart ssh sudo systemctl restart sshd.service
Update sshd_config with following:
ChallengeResponseAuthentication yes PasswordAuthentication no
Run command google-authenticator
Please help me resolve this issue. Thanks in advance.
I was facing this issue because of other configuration was enabled. PubKeyAuthentication was used instead of authenticator. I change it to PubKeyAuthentication no which resolved the issue.

what is the default password for the `jupyter` user on AI platform notebook VMs?

i just tried to install oh-my-zsh on my notebook instance. it asked for the jupyter user's password, but i have no idea.
i'm also tagging with gcp-ai-platform-notebook as the support page says to do. thanks in advance for any help here!
I tried to install oh-my-zsh using “sudo -i" to login as root. It’s installed successfully. So, I would advise you to use “sudo -i” to login as root before installing oh-my-zsh.
You can change the password using the following
sudo passwd <username>
You will require sudo permissions. This can be done by adding Compute Admin role to the service account and restarting the VM

AWS EC2 default password

I'm following this tutorial to host a website with an apache server. The thing is that the last step tells my to do
service apache2 reload
But it asks me for a password. I don't remember inserting a password for this VM, just the .pem I used to log in.
Is there a default password? Or how can I solve this? Sorry if this is basic, but the most complex thing I've done with servers is with wamp and xamp
Thanks!
Based on the comments, the solution was to use sudo:
sudo service apache2 reload

Google Compute Engine - can't ssh to it after debian upgrade

I upgraded my Debian instance from wheezy to jessie. Everything went well. I rebooted the system and couldn't ssh to it anymore from the compute engine instance page. I noticed the system did reboot, with a different external IP address. I'm able to get to a web server I have running on the virtual machine, so I know everything upgraded and rebooted properly. Google assigned a new external IP to it and I can't login anymore.
the fact that sshd is no longer running is very unlikely, so here is my personal debug steps when I can't reach an instance on Google Cloud:
Check twice you ssh parameters (ssh keys, login user, ip address)
Activate ssh debug logs (-v) when you try to connect
Try using Cloud Shell
Check firewall rules in GCP and on your local network
Check the boot logs on the instance serial port
Re-send you SSH key in GCP > Compute > Metadata (bugs occurs sometime with the google user agent on your machine)
After that, you normally know how to connect to your instance or you know what's wrong with sshd server.
You can review the serial-port logs of the affected instance for possible clue on the issue. If you have a snapshot of your instance disk, you can create a new VM. As per the issue, is possible that recent changes may have affected the instance boot sequence and the sshd_config file.
To troubleshoot this, you can enable interactive access, connect to the instance through the serial console and enter the serial port access information to access the disk, review the ssh config files$ sudo vi /etc/ssh/sshd_config and $ sudo vi /etc/ssh/ssh_config.
If you don’t have a root password for the serial console, you could use a startup script to add it to your instance as follows:
Go to the VM instances page in Google Cloud Platform console.
Click on the instance for which you want to add a startup script.
Click the Edit button at the top of the page.
Click on ‘Enable connecting to serial ports’
Under Custom metadata, click Add item.
Set 'Key' to 'startup-script' and set 'Value' to this script:
#! /bin/bash
useradd -G sudo USERNAME
echo 'USERNAME:PASSWORD' | chpasswd
Example:
#! /bin/bash
useradd -G sudo test1
echo 'test1:pass#100' | chpasswd
Click Save and then click RESET at the top of the page. You might need to wait for some time for the instance to reboot.
Click on 'Connect to serial port' on the page.
In the new window, you might need to wait a bit and press the Enter of your keyboard once; then, you should see the login prompt.
10.. Login using the USERNAME and PASSWORD you provided.
Example:
Username: test1 AND Password: pass#100
You can also share a sanitized version of the serial port logs, for more information on what may be happening on the instance. This is not due to a change in IP address, however the serial port logs should give us more insight.

Installed cPanel -amp- WHM- AMI on AWS - Can't Login to WHM or cPanel

I installed the cPanel & WHM: The Hosting Platform of Choice AMI on AWS last night on a ec2 instance.
It seems to have set it all up and I can get to the login pages of cPanel and WHM but can not log in.
I used the 1-click install and never entered, or was given a user/password combination.
Where can I find or set this information?
I can login through ssh from the aws portal and there is definitely a password set. I tried using
sudo mysql_secure_installation
to reset it but failed to login because I did not have a password. It is not blank.
I am not very familiar with doing things through SSH so please be specific on how to fix this if I need to do it through SSH.
Thank you so much for your help.
Any advice or suggestions about AWS is greatly appreciated.
I think there is an issues with the port/firewall setting. Please enable all cPanel require ports for your AWS and try to login cPanel/WHM.
Here are the all port lists which you need to enable for your server.
https://documentation.cpanel.net/pages/viewpage.action?pageId=7536715#HowtoConfigureYourFirewallforcPanel&WHM%27sServices-Ports
Amazon doesn't allow you to connect through the dashboard as root, you have to login as the user type. In this case, ec2-user. Logged in as this user doesn't allow you use the "passwd" command without the old password. However, you can authenticate as root, then use the passwd command to change the password without having to know the old one/default install. Here's how.
Log into SSH in as the ec2-user.
Run "sudo -i" to authenticate as root.
Once you're "root", you can reset the root password using "passwd".
Then login to WHM.
Looks like you've missed some step before
wget -N http://httpupdate.cpanel.net/latest
I've got the same issue and ended with deleting the instance and staring over.
The only setup guide that worked for me without any issues: https://5best.cloud/build-cpanel-cloud-hosting-amazon-aws-1/