Steps to reproduce:
This has been tested on ubuntu-2004-focal-v20210927 and 
ubuntu-minimal-1804-bionic-v20210915.

Ensure new-user1 and new-user2 do not have ssh keys in the project
metadata.

1, Create a new instance and apply OS updates:
gcloud compute instances create ssh-test-image --machine-type=f1-micro 
--image=ubuntu-2004-focal-v20210927 --image-project=ubuntu-os-cloud 
--metadata=startup-script=\#\!/bin/bash$'\n'apt-get\ update$'\n'apt-get\ -y\ 
dist-upgrade --zone=europe-west4-a

gcloud compute instances tail-serial-port-output ssh-test-image
--zone=europe-west4-a

Wait for finish e.g. 'Startup finished in X.XXs (kernel) + Xmin XX.XXXs
(userspace) = Xmin XX.XXXs.' then press Ctrl+C

2, Stop instance and create an image:
gcloud compute instances stop ssh-test-image --zone=europe-west4-a


gcloud compute images create ssh-test-image --source-disk=ssh-test-image 
--source-disk-zone=europe-west4-a

3, Create a new instance from the image:
gcloud compute instances create ssh-test-instance --machine-type=f1-micro 
--image=ssh-test-image --zone=europe-west4-a

gcloud compute instances tail-serial-port-output ssh-test-instance
--zone=europe-west4-a

# Wait for finish e.g. 'Startup finished in X.XXs (kernel) + XX.XXXs
(userspace) = XX.XXXs.'  then press Ctrl+C

4, Attempt to connect with a new user:
gcloud compute ssh new-user1@ssh-test-instance --zone=europe-west4-a 
Updating project ssh metadata...⠹Updated 
[https://www.googleapis.com/compute/v1/projects/kaboodle-labs].                 
                                                                                
         
Updating project ssh metadata...done.                                           
                                                                                
                                                  
Waiting for SSH key to propagate.
Warning: Permanently added 'compute.9106208184098581676' (ECDSA) to the list of 
known hosts.
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).
ERROR: (gcloud.compute.ssh) Could not SSH into the instance.  It is possible 
that your SSH key has not propagated to the instance yet. Try running this 
command again.  If you still cannot connect, verify that the firewall and 
instance are set to accept ssh traffic.

5, Restart the instance and attempt to connect again
gcloud compute instances stop ssh-test-instance --zone=europe-west4-a

gcloud compute instances start ssh-test-instance --zone=europe-west4-a

gcloud compute ssh new-user1@ssh-test-instance --zone=europe-west4-a
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-1020-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Oct  7 12:01:41 UTC 2021

  System load:  0.98              Processes:             101
  Usage of /:   19.0% of 9.52GB   Users logged in:       0
  Memory usage: 31%               IPv4 address for ens4: 10.164.0.28
  Swap usage:   0%

0 updates can be applied immediately.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

new-user1@ssh-test-instance:~$ logout

gcloud compute ssh new-user2@ssh-test-instance --zone=europe-west4-a
Updating project ssh metadata...⠛Updated 
[https://www.googleapis.com/compute/v1/projects/********].                      
                                                                                
    
Updating project ssh metadata...done.                                           
                                                                                
                                                  
Waiting for SSH key to propagate.
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-1020-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Oct  7 12:02:31 UTC 2021

  System load:  0.46              Processes:             99
  Usage of /:   19.0% of 9.52GB   Users logged in:       0
  Memory usage: 30%               IPv4 address for ens4: 10.164.0.28
  Swap usage:   0%


0 updates can be applied immediately.


new-user2@ssh-test-instance:~$ logout

6, Cleanup
gcloud compute instances delete ssh-test-image --zone=europe-west4-a
gcloud compute instances delete ssh-test-instance --zone=europe-west4-a
gcloud compute images delete ssh-test-image

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1946358

Title:
  Unable to SSH after update and image

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/google-guest-agent/+bug/1946358/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to