GCPのCloud Shellにscpできなかったメモ

GCPのCloud Shellにscpできなかったメモ:


発生した問題

公式ドキュメント によると以下のコマンドでできそうだったができなかった。

$ gcloud alpha cloud-shell scp localhost:$/path/to/file cloudshell:~/ 
gotch@xxx.xxx.xxx.xxx: Permission denied (publickey). 
lost connection 
ERROR: (gcloud.alpha.cloud-shell.scp) [/usr/bin/scp] exited with return code [1]. 


解決

これでできた。

$ /usr/bin/scp -P 6000 -i /Users/gotch/.ssh/google_compute_engine -o StrictHostKeyChecking=no /path/to/file gcpuser@xxx.xxx.xxx.xxx:~/ 
gcpuser は gcpにログインできるユーザー名。


コマンドを調べたメモ

--verbosity debug をつけて実行すると実際のコマンドが調べられる。

$ gcloud alpha cloud-shell scp --verbosity debug localhost:$/path/to/file cloudshell:~/ 
... 
DEBUG: Running command [/usr/bin/scp -P 6000 -i /Users/gotch/.ssh/google_compute_engine -o StrictHostKeyChecking=no /path/to/file xxx.xxx.xxx.xxx:~/]. 
... 
... 
ERROR: (gcloud.alpha.cloud-shell.scp) [/usr/bin/scp] exited with return code [1]. 
下記のコマンドを実行していると思われる。

$ /usr/bin/scp -P 6000 -i /Users/gotch/.ssh/google_compute_engine -o StrictHostKeyChecking=no /path/to/file xxx.xxx.xxx.xxx:~/ 
もともとsshはできていたのでsshも確認

$ gcloud alpha cloud-shell ssh --verbosity debug  
... 
DEBUG: Running command [/usr/bin/ssh -t -p 6000 -i /Users/gotch/.ssh/google_compute_engine -o StrictHostKeyChecking=no styz_dev@104.199.248.214 -- DEVSHELL_PROJECT_ID=syncable-app-test bash -l]. 
... 
下記のコマンドを実行していると思われる。

$ /usr/bin/ssh -t -p 6000 -i /Users/gotch/.ssh/google_compute_engine -o StrictHostKeyChecking=no gcpuser@xxx.xxx.xxx.xxx -- DEVSHELL_PROJECT_ID=your_project_id bash -l 
接続先にユーザーが入っていない。

他の解決策があるのではないだろうか��

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)