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 
接続先にユーザーが入っていない。

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

コメント

このブログの人気の投稿

投稿時間:2020-07-01 05:34:30 RSSフィード2020-07-01 05:00 分まとめ(37件)

投稿時間:2020-07-01 20:43:40 RSSフィード2020-07-01 20:00 分まとめ(81件)

投稿時間:2020-07-01 08:33:22 RSSフィード2020-07-01 08:00 分まとめ(49件)