0

I followed this tutorial on how to setup a GCE-VM with ssh. However i can't seem to successfully connect via ssh as the guy from the video did! This is the output when i try connecting (IP is fictional):

~ λ ssh -v 34.89.154.144
OpenSSH_8.3p1, OpenSSL 1.1.1h  22 Sep 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 34.89.154.144 [34.89.154.144] port 22.
debug1: Connection established.
debug1: identity file /home/tim/.ssh/id_rsa type 0
debug1: identity file /home/tim/.ssh/id_rsa-cert type -1
debug1: identity file /home/tim/.ssh/id_dsa type -1
debug1: identity file /home/tim/.ssh/id_dsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa type -1
debug1: identity file /home/tim/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/tim/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519 type -1
debug1: identity file /home/tim/.ssh/id_ed25519-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519_sk type -1
debug1: identity file /home/tim/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/tim/.ssh/id_xmss type -1
debug1: identity file /home/tim/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.10
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.10 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to 34.89.154.144:22 as 'tim'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:w2LwJiLfvysv6AJDqA6R0u5dZuXVbwdqXsQCZ0IhlT8
debug1: Host '34.89.154.144' is known and matches the ECDSA host key.
debug1: Found key in /home/tim/.ssh/known_hosts:2
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/tim/.ssh/id_rsa RSA SHA256:DDVIWu+4qABFT+8uCSJuZ9bSh4y1FH+zAW2owNw1J7I
debug1: Will attempt key: /home/tim/.ssh/id_dsa
debug1: Will attempt key: /home/tim/.ssh/id_ecdsa
debug1: Will attempt key: /home/tim/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/tim/.ssh/id_ed25519
debug1: Will attempt key: /home/tim/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/tim/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/tim/.ssh/id_rsa RSA SHA256:DDVIWu+4qABFT+8uCSJuZ9bSh4y1FH+zAW2owNw1J7I
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/tim/.ssh/id_dsa
debug1: Trying private key: /home/tim/.ssh/id_ecdsa
debug1: Trying private key: /home/tim/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/tim/.ssh/id_ed25519
debug1: Trying private key: /home/tim/.ssh/id_ed25519_sk
debug1: Trying private key: /home/tim/.ssh/id_xmss
debug1: No more authentication methods to try.
tim@34.89.154.144: Permission denied (publickey).

Things i've tried to solve this:

  1. Set up the VM in a different region (asia instead of europe)
  2. Set up the VM with a different image (debian, ubuntu, minimal and standard)
  3. Try the setup under Windows and Linux
  4. enable-oslogin = TRUE project-wide and for the particular instance
  5. Delete host-portion from the public ssh-key
  6. ssh [IP], ssh [USER_IN_KEY]@[IP], ssh [USER_ON_VM]@[IP]

I actually don't know where to look for issues anymore! Can anyone give me a pointer or suggestions on what i could try out or where the issue might be?

Thanks!

Tim Hilt
  • 135
  • 5

2 Answers2

0

I tried to reproduce the error in my own project in a new VM Instance and following the video you mentioned, and I received the same error you received:

ssh <MY-IP>
The authenticity of host '<MY-IP> (<MY-IP>)' can't be established.
ECDSA key fingerprint is SHA256:A....
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<MY-IP>' (ECDSA) to the list of known hosts.
<MY-USER>@<MY-IP>: Permission denied (publickey).

I followed this steps: Connecting using third-party tools instead and I was able to connect my Debian using ssh to my new Instance:

ssh -i <my-private-ssh-key> <MY-IP>
Linux <MY-INSTANCE-NAME> 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64

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

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Oct  1 14:50:16 2020 from <SOME-IP>
<MY-USER>s@<MY-INSTANCE-NAME>:~$ hostname
<MY-INSTANCE-NAME>

Another good option is to install Google Cloud SDK and then use

gcloud compute ssh --project <PROJECT_ID> --zone <ZONE> <VM-INSTANCE_NAME>

You could see the following link for more information.

0

Adding ssh public-key to your (os-login) metadata server should fix the issue,Try these commands using gcloud SDK or in cloud shell

gcloud auth login    
gcloud config set project *project-name*
gcloud compute os-login ssh-keys add --key-file ../path/to/public/key

and check if you have got the right roles to login with os-login method

 log-in with out sudo permissions   : roles/compute.oslogin   
 log-in with sudo permissions       : roles/compute.osAdminlogin