I have an external instance IP which is setup correctly with my SSH keys. If I run the following code to access the GCP instance.
>> ssh <instance IP>
# Login happens
>> gcloud <some command>
# Gcloud outputs as expected
However, I can't run the gcloud
command directly over ssh. That is
>> ssh <instance IP> gcloud <some command>
bash: gcloud: command not found
I believe this is the root cause of some issues I am seeing where I have permissions to run commands if I manually ssh and run in the interactive shell, but not if I pass the command through ssh.
I have tried
>> ssh <INSTANCE IP> -t "source ~/.bashrc; gcloud auth list"
bash: gcloud: command not found
>> gcloud compute ssh instance-name -- -t "gcloud"
bash: gcloud: command not found
>> gcloud compute ssh instance-name --command="gcloud"
bash: gcloud: command not found
and similar tricks around bashrc and gcloud, but there's nothing google-related in there I can see immediately anyway.
The instances are running Ubuntu 20.04, more or less fresh images. The problem is there between instances, or on my local machine connecting to instances.
I suspect I'm missing something simple here - any takers?
ssh <instance-external-IP-addr> -t "/usr/bin/gcloud auth list"
gcloud
is configured per user. Are you using the same identity to login via both methods. Use the Linux commandenv
to double-check the environment under both login methods.