2

Yesterday, I was able to connect to my VM without any problem. Today, when I wanted to connect, it just loops over "Transferring SSH keys to VM". When I go in the console, it loops the same thing.

[   25.428229] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:01 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:15 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   39.234910] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:15 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:23 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   47.503004] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:23 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:36 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   59.781896] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:36 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:51 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   74.833424] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:51 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:59 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   83.592217] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:47:59 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[   97.555182] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:22 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  106.502914] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:22 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:36 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  119.896296] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:36 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:45 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  128.957112] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:48:45 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:00 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  143.811024] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:00 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:08 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  152.070307] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:08 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:19 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  162.842013] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:19 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:38 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  182.018657] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:38 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:47 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  191.222629] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:47 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:55 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  199.263207] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:49:55 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:27 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  230.928268] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:27 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:35 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  238.824908] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:35 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:47 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  250.926710] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:47 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:58 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  262.463967] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:50:58 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  277.107377] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:26 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  290.104692] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:26 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:42 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  306.256838] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:51:42 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  337.130106] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:21 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  345.671107] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:21 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:43 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  366.956060] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:43 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:54 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  377.735550] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:52:54 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:13 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  397.431086] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:13 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:25 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  409.300145] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:25 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:44 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  428.298872] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:53:44 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:06 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  449.817168] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:06 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:24 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  468.097514] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:24 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:35 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  478.724337] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:35 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:46 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  490.143037] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:54:46 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:00 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  504.095877] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:00 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:10 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  514.511027] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:10 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:28 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  532.547638] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:28 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:37 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  541.349512] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:37 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:48 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  551.846271] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:55:48 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:07 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  571.265681] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:07 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:15 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  579.655513] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:15 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:27 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  591.267328] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:27 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:38 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  601.824841] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:38 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:44 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  608.365183] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:56:44 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:02 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  625.816933] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:02 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:11 winter-lounge google-accounts: INFO Adding user gurvanbk to the Google sudoers group.
[  634.738381] google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers
Mar 27 07:57:11 winter-lounge google_accounts_daemon[723]: Adding user gurvanbk to group google-sudoers

I don't know how to do to connect to my VM instance now. Could anyone helps me?


We asked me for boot logs, but I don't know how to read them, I put the full log here, and put in evidence some things that could be errors/fails/warns. Full log (extremely long): https://hastebin.com/akipiwupuw.coffeescript

Some errors/fails/warns:

[    0.362757] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.363735] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
Mar 27 09:05:47 winter-lounge ntpd[664]: bind(21) AF_INET6 fe80::4001:aff:fea4:2%2#123 flags 0x11 failed: Cannot assign requested address
Mar 27 09:05:47 winter-lounge ntpd[664]: unable to create socket on eth0 (5) for fe80::4001:aff:fea4:2%2#123
Mar 27 09:05:47 winter-lounge ntpd[664]: failed to init interface for address fe80::4001:aff:fea4:2%2
Mar 27 09:05:46 localhost kernel: [    0.928475] i8042: Warning: Keylock active
Mar 27 09:05:46 localhost kernel: [    3.322253] random: 7 urandom warning(s) missed due to ratelimiting

Steps I followed when using "Managing SSH keys in metadata" guide: (I'm on windows)

 1. Downloaded `puttygen.exe`
 2. Used it to create SSH keys pair, with "gurvanbk" as comment
 3. Didn't set key passphrase
 4. Saved private key on my "Documents" folder
 5. Saved public key in the same folder
 6. Checked public key format: Good
 7. Went to Metadata page
 8. Went into the "SSH keys section"
 9. Deleted all SSH keys for user "gurvanbk"
 10. Added my manually created SSH key (public)
 11. Saved
 12. Went on my VM instances page
 13. Clicked the SSH button
 14. Window opened
 15. Keeps looping "Creating SSH keys"
Gugu72
  • 121
  • 5
  • Is it possible for your to restart your instance, check boot logs at `Serial port (console)` and add them to your question? In addition, try to add temporary user and password via startup script as it described [here](https://medium.com/google-cloud/resolving-getting-locked-out-of-a-compute-engine-85800251890b) – Serhii Rohoza Mar 27 '20 at 08:57
  • Hey, I restarted my instance, I will try to find that logs. – Gugu72 Mar 27 '20 at 09:00
  • In addition, try to enable serial ports connections as well to be able to login to your VM with your temporary credentials. – Serhii Rohoza Mar 27 '20 at 09:06
  • Hey, I have boot logs, but they are extremely long and I'm wondering if there is personal information (such as access, IPs) in? – Gugu72 Mar 27 '20 at 09:08
  • You can replace IPs with XX.XX.XX.XX and username with something else. Also, you can check log on your own - try to find any errors related to disk space and ssh. – Serhii Rohoza Mar 27 '20 at 09:10
  • I don't know how to read that logs, and they are extremely long – Gugu72 Mar 27 '20 at 09:11
  • Copy them to text editor and search for `error`, `warning`, `space` and so on. – Serhii Rohoza Mar 27 '20 at 09:13
  • That? `Mar 27 09:05:46 localhost kernel: [ 0.363735] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.` – Gugu72 Mar 27 '20 at 09:15
  • Find and copy everything that could be related to [Pastebin](https://pastebin.com/) and share link when you finish. – Serhii Rohoza Mar 27 '20 at 09:18
  • Sent full logs to hastebin and some lines here (in edited answer) – Gugu72 Mar 27 '20 at 09:22
  • Thanks! Did you enable console login? Have tried to SSH after reboot? – Serhii Rohoza Mar 27 '20 at 09:29
  • Even after reboot, SSH doesn't work. And no, I didn't enabled them, I'm gonna do – Gugu72 Mar 27 '20 at 09:30
  • I enabled console login, what do you want I do in the console? – Gugu72 Mar 27 '20 at 09:36
  • Do you have access to you VM via console with temporary credentials? Check free space with `df -h` and permissions `ls -la ~/.ssh` and `ls -la ~/.ssh/` – Serhii Rohoza Mar 27 '20 at 09:45
  • I folowed the guideline you gave me, but it says login incorrect I'm using tempuser / password, but that doesn't work – Gugu72 Mar 27 '20 at 09:55
  • Also may be useful, I have set up an FTP connection to use with FileZilla, and that works. – Gugu72 Mar 27 '20 at 10:02
  • Try to follow instruction from this [document](https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh), also check this [script](https://github.com/GoogleCloudPlatform/compute-ssh-diagnostic-sh) – Serhii Rohoza Mar 27 '20 at 10:06
  • I followed the document, and when I reached the part they tell to use `gcloud compute ssh another-username@$PROB_INSTANCE`, it worked. What does that mean? It seems my sshkeys are not properly defined for the main user? – Gugu72 Mar 27 '20 at 10:23
  • Do you have the same issue with other instance with your main account? – Serhii Rohoza Mar 27 '20 at 10:33
  • I only have 1 instance – Gugu72 Mar 27 '20 at 10:34
  • Check permissions for both of your accounts `ls -la /home/USER_NAME/.ssh` and `ls -la /home/USER_NAME/.ssh/`. If they're different - set on your main account same permissions as you found for temporary with `chmod` command. – Serhii Rohoza Mar 27 '20 at 10:38
  • I have that : http://cubeupload.com/im/Gugu72/Annotation2020032711.png – Gugu72 Mar 27 '20 at 10:47
  • Try delete `.ssh` folder for your main account with command `rm -rf /home/gurvanbk/.ssh`. It'll be recreated on next login. I've checked on my test VM. – Serhii Rohoza Mar 27 '20 at 10:54
  • Do I need to restart my machine or remove something else? – Gugu72 Mar 27 '20 at 11:02
  • Nope, just remove and try to reconnect. – Serhii Rohoza Mar 27 '20 at 11:09

3 Answers3

0

I found nothing suspicious in your console log and because FTP connection works fine the issue directly related to SSH connectivity.

Try to follow Troubleshooting SSH section Connect as a different user:

The issue that prevents you from logging in might be limited to your user account. For example, the permissions on the ~/.ssh/authorized_keys file on the instance might not be set correctly for the user.

Try logging in as a different user with the gcloud tool by specifying another-username with the SSH request. The gcloud tool will update the project's metadata to add the new user and allow SSH access.

gcloud compute ssh another-username@$PROB_INSTANCE

If you succeeded try to remove .ssh folder from your main account and try to login again - it'll be recreated automatically on your next login.

Do not forget to disable login via console and remove temporary user that you've tried to add via startup script.

Serhii Rohoza
  • 1,424
  • 2
  • 5
  • 15
  • Hey, I deleted the .ssh of my main account, tried reconnecting but still not working. I tried to use the command in your answer with "gurvanbk" instead of "another-username", it is asking me a password of gurvanbk@compute...... http://cubeupload.com/im/Gugu72/Annotation2020032712.png What password should I put here? – Gugu72 Mar 27 '20 at 11:48
  • Have you tried to add temporary password for gurvanbk? Is possible for you to remove this user from VM completely? Try to connect to your instance via Cloud UI. – Serhii Rohoza Mar 27 '20 at 12:03
  • Temp password works, but it says `Permission denied` Also, I can't remove this user because my files are on this user, but I could move them. I will try Cloud UI. EDIT: I don't know how to use Cloud UI, can you explain? Also, if I delete the main user, how would I connect myself to the VM without having the user? Will it recreate it? – Gugu72 Mar 27 '20 at 12:08
  • If you have some data under that user keep it. Have you removed `.ssh` folder for your main user? Cloud UI it's a web interface for GCP. Go to Compute Engine -> VM instances -> and you'll see SSH button to connect to your instance. – Serhii Rohoza Mar 27 '20 at 12:41
  • Ok, yeah I removed the .ssh folder from the main user. And, uhh, that is the thing I'm actually wanting to use... (the SSH button) – Gugu72 Mar 27 '20 at 12:43
  • What's the result? If still the same try to follow [Managing SSH keys in metadata](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys). – Serhii Rohoza Mar 27 '20 at 14:23
  • Since the beginning, I'm using the SSH button... not something else – Gugu72 Mar 27 '20 at 14:40
  • So, you still have an issue, am I right? What happened when you press SSH button? Do you have any new messages in console log? Have you tried to use your own SSH key as I suggested? – Serhii Rohoza Mar 27 '20 at 16:19
  • All things I explained since the beginning are with the SSH button. It just infinite lops over transferring ssh keys. Now I'm testing to manage the metadata – Gugu72 Mar 27 '20 at 16:29
  • Have you succeeded with metadata? – Serhii Rohoza Mar 30 '20 at 10:10
  • No, I deleted both metadata and machine ssh keys, but it still not working. I success to connect via log console – Gugu72 Mar 30 '20 at 13:25
  • What was the error when you added ssh keys manually? – Serhii Rohoza Mar 30 '20 at 14:55
  • I never added SSH keys manually, did you told me to do? Also, I don't know how to do in that case, could you tell me how to do? – Gugu72 Mar 30 '20 at 14:56
  • Please have a look "What's the result? If still the same try to follow [Managing SSH keys in metadata](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys). – Serhii Rohoza Mar 27 at 14:23". You could try to add ssh key manually by following this guide. I thought you've tried "Now I'm testing to manage the metadata – Gugu72 2 days ago" – Serhii Rohoza Mar 30 '20 at 14:58
  • Yeah, I deleted all keys, but didn't added mine after – Gugu72 Mar 30 '20 at 15:08
  • I did it now, and after clicking the SSH button, it still does the same thing, and it creates **new SSH keys** even if I added mine! I had only one, the one I did manually, but it adds other and other SSH keys, I now have 4 SSH keys for the same user, it is not understandable. – Gugu72 Mar 30 '20 at 15:24
  • SSH keys are created automatically by Compute Engine as you can see in the [documentation](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) . For your second user you have automatically created SSH keys as well. – Serhii Rohoza Mar 30 '20 at 15:53
  • It is creating 4 keys... – Gugu72 Mar 30 '20 at 15:54
  • If you check for your second user you'll found the same amount of SSH keys. – Serhii Rohoza Mar 30 '20 at 15:59
  • No, it keeps creating new ones, without connecting, just adding keys – Gugu72 Mar 30 '20 at 16:01
  • I have 8 SSH keys... Instead of counting SSH keys please update your question with your steps, commands and outputs while following [Managing SSH keys in metadata](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) when you've tried to add your own SSH keys. – Serhii Rohoza Mar 30 '20 at 16:07
  • I literally followed the guide... – Gugu72 Mar 30 '20 at 16:07
  • Sorry, but without your steps, commands and outputs it's hard to find what's wrong with your VM. At least you have SSH access via second account. – Serhii Rohoza Mar 30 '20 at 16:09
  • I'm switching to my computer to edit, it is easier – Gugu72 Mar 30 '20 at 16:10
  • Also, I can use the cloud shell to connect to my VM instance with **my main account**, it is working – Gugu72 Mar 30 '20 at 16:15
  • Do you have problem with connection to you VM only via Cloud SDK like `gcloud compute ssh --project [PROJECT_ID] --zone [ZONE] [INSTANCE_NAME]`? – Serhii Rohoza Mar 30 '20 at 16:17
  • Nope, I don't have any bug, it works – Gugu72 Mar 30 '20 at 16:29
  • Okay. The problem only limited to SSH via web browser, am I right? Which web browser do you use? Do you have any extensions installed? – Serhii Rohoza Mar 30 '20 at 16:41
  • I use Chrome. Yeah I have some extensions installed, but nothing that modify page and it worked before. – Gugu72 Mar 30 '20 at 16:43
  • Try another browser (Firefox for example) just to be sure that there's no issue with your web browser. I've seen some weird issues with ad blockers and GCP. – Serhii Rohoza Mar 30 '20 at 16:49
  • Ok, I will do and tell you what happens. – Gugu72 Mar 30 '20 at 17:02
0

I see that you have a VM that seems to be Linux, and you're connecting to it via a terminal running on a Windows Machine via Web Browser.

It seems that you're looking into Manually Managing the SSH keys on the VM's metadata, this is a way that can be risky. As we can read in these documentation: [1][2][3].

As we also can read on [4], here's an excerpt of it:

"When you remove all the SSH keys for the user account from metadata, the authorized keys file for a Google-managed user account is deleted."

From what I can read on all the comments, someone provided really nice information to answer your question.

Also I would like to share this document [5] with you.

It looks that the issue was related to your web browser or its extensions. Would you please share about this?


[1] https://cloud.google.com/sdk/gcloud/reference/compute/instances/remove-metadata

[2] https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys

[3] https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#risks

[4] https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh

[5] https://stackoverflow.com/help/how-to-ask"

Carlo C.
  • 107
  • 1
  • 8
  • 1
    Hi Carlo, Since my issue, I changed computer, I'm now on a Mac. Anyways, I found another way to get it work, and it's working. I can connect through Cloud Shell with another account I created. This account has Sudo and everything. Also, this is not related to my browsers nor extensions, I tested on 3 computer and 2 browsers, it is still not working. I don't need any help now :) Thanks – Gugu72 Sep 01 '20 at 14:42
0

There's one more method to access VM's that is almost foolproof - serial console.

You have to enable serial console access to that particular VM using console or a gcloud command:

gcloud compute instances add-metadata instance-name \
    --metadata serial-port-enable=TRUE

and connect to it using console or a gcloud: https://cloud.google.com/compute/docs/instances/interacting-with-serial-console#connectserialconsole

But - if you don't know the credentials you may have to create them; easiest way is to set up a startup script that will create a user and a password that we define and then we can use them to login in (either via console or later via SSH).

Sample script (for Debian VM's - works as well on RHEL 8) will look like this:

#! /bin/bash
adduser username
echo 'username:userspass' | chpasswd
usermod -aG google-sudoers username

Connecting via serial console is the last resord but if other fail then this is the on to go. It will fail only when there's something really wrong with the OS (system disk full, files corrupted etc).

I've explained this in more detail on another such issue on SO.

Wojtek_B
  • 1,013
  • 4
  • 14