bk7
bk7

Reputation: 33

Best practice for SSH credentials for outbound connections from Google Cloud Shell

I have private GIT repo on Bitbucket and would like to push changes I make on Google Cloud Shell back there.

I've enabled Bitbucket -> GCP mirroring, but that seems to be non-bi-directional, i.e.

git push origin master
fatal: remote error: The remote repository is a read-only mirror of https://bitbucket.org/<repo_name>

For now, I just added one more remote that points directly to Bitbucket and generated a new SSH key pair to connect:

git remote add bitbucket [email protected]:<user>/<repo_name>.git
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub

Git push seems to work fine:

$ git push bitbucket master
Everything up-to-date 

But now the question: will ~/.ssh survive Cloud Shell VM restart? What is the best practice?

Upvotes: 1

Views: 122

Answers (1)

noobmaster69
noobmaster69

Reputation: 192

.ssh will survive for next session as system wide changes will be changed not the changes in $HOME directory. If you come back before 120 days, you will have the .ssh file. But you might need to install "git" again to use it. For more details I would recommend the following link:
https://cloud.google.com/shell/docs/limitations
How does the data in HOME directory persist on cloud shell?

Upvotes: 1

Related Questions