Score:0

Can't ssh into cloud shell

jp flag

I try to ssh from my local host to GCP cloud shell and get the error:

$ gcloud cloud-shell ssh --authorize-session
sign_and_send_pubkey: signing failed for RSA "/home/kossak/.ssh/google_compute_engine" from agent: agent refused operation
<USER>@<IP>: Permission denied (publickey).
ERROR: (gcloud.cloud-shell.ssh) [/usr/bin/ssh] exited with return code [255].

with debug option:

$ gcloud cloud-shell ssh --authorize-session --verbosity debug
DEBUG: Running [gcloud.cloud-shell.ssh] with arguments: [--authorize-session: "True", --verbosity: "debug"]
DEBUG: Starting new HTTPS connection (1): cloudshell.googleapis.com:443
DEBUG: https://cloudshell.googleapis.com:443 "GET /v1/users/me/environments/default?alt=json HTTP/1.1" 200 None
DEBUG: Starting new HTTPS connection (1): cloudshell.googleapis.com:443
DEBUG: https://cloudshell.googleapis.com:443 "POST /v1/users/me/environments/default:authorize?alt=json HTTP/1.1" 200 None
DEBUG: Running command [/usr/bin/ssh -t -p 6000 -i /home/kossak/.ssh/google_compute_engine -o StrictHostKeyChecking=no <USER>@<IP> -- DEVSHELL_PROJECT_ID=<PROJECT_ID> bash -l].
DEBUG: Executing command: ['/usr/bin/ssh', '-t', '-p', '6000', '-i', '/home/kossak/.ssh/google_compute_engine', '-o', 'StrictHostKeyChecking=no', '<USER>@<IP>', '--', 'DEVSHELL_PROJECT_ID=<PROJECT_ID>', 'bash -l']
sign_and_send_pubkey: signing failed for RSA "/home/kossak/.ssh/google_compute_engine" from agent: agent refused operation
<USER>@<IP>: Permission denied (publickey).
DEBUG: (gcloud.cloud-shell.ssh) [/usr/bin/ssh] exited with return code [255].
Traceback (most recent call last):
  File "/home/kossak/apps/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 987, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/home/kossak/apps/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 807, in Run
    resources = command_instance.Run(args)
  File "/home/kossak/apps/google-cloud-sdk/lib/surface/cloud_shell/ssh.py", line 114, in Run
    command.Run(connection_info.ssh_env)
  File "/home/kossak/apps/google-cloud-sdk/lib/googlecloudsdk/command_lib/util/ssh/ssh.py", line 1541, in Run
    raise CommandError(args[0], return_code=status)
googlecloudsdk.command_lib.util.ssh.ssh.CommandError: [/usr/bin/ssh] exited with return code [255].
ERROR: (gcloud.cloud-shell.ssh) [/usr/bin/ssh] exited with return code [255].

What I tried already:

  • restarting ssh-agent on local machine
  • rebooting my local machine and cloud shell
  • gcloud compute config-ssh (on both local machine and cloud shell) returned only WARNING: No host aliases were added to your SSH configs because instances have no public IP.
  • removing all ssh keys from GCP Compute => Metadata => SSH Keys
  • renaming ~/.ssh and trying to connect again
  • ssh-add -l returns both of my keys: rsa (from gcp) and ed25519 (created manually)
  • permissions of /home/kossak/.ssh are 700
  • permissions of /home/kossak/.ssh/google_compute_engine are 600
  • connecting to another SSH server in my local network with a ssh key - works properly
  • executing git commands with ssh key authorization (eg git remote update) - works properly

I use:

  • Linux Manjaro
  • Google Cloud SDK 410.0.0

I can login to cloud shell from another host so the problem is probably with my computer. Anybody knows what's wrong or how to debug it?

Thank you for any advice.

Jeffrey D. avatar
cl flag
You can review this [stock overflow link](https://stackoverflow.com/questions/26193535/error-gcloud-compute-ssh-usr-bin-ssh-exited-with-return-code-255) with your same, ERROR: (gcloud.cloud-shell.ssh) [/usr/bin/ssh] exited with return code [255].
John Hanley avatar
cn flag
What are the permissions (ls -ld) for `/home/kossak/.ssh` and `/home/kossak/.ssh/google_compute_engine`?
Kossak avatar
jp flag
@JohnHanley they seem to be ok: 700 for `~/.ssh` and 600 for `~/.ssh/google_compute_engine`
Kossak avatar
jp flag
@JeffreyD. tried many solutions from the other topic (updated this topic with what I tried), but no luck so far...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.