GitHub Codespacesにssh接続する
ghコマンドをダウンロード
zip展開
実行
code:shhell
% ./gh auth login
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? Skip
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: 55DC-15A3
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Logged in as shimizukawa
接続(失敗1)
code:shell
% ./gh codespace ssh
This API operation needs the "codespace" scope. To request it, run: gh auth refresh -h github.com -s codespace
認証トークンを更新
code:shell
% ./gh auth refresh -h github.com -s codespace
! Using secure storage could break installed extensions
! First copy your one-time code: E74C-7F54
Press Enter to open github.com in your browser...
✓ Authentication complete.
接続(失敗2)
code:shell
% ./gh codespace ssh
shimizukawa/huggingface-document-search (main): bookish waffle
sphinx-doc/sphinx-intl (master): orange system
error getting ssh server details: failed to start SSH server:
Please check if an SSH server is installed in the container.
If the docker image being used for the codespace does not have an SSH server,
install it in your Dockerfile or, for codespaces that use Debian-based images,
you can add the following to your devcontainer.json:
"features": {
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
}
}
既存のインスタンスに apt get install sshd してもOKでした
接続(成功)
code:shell
shimizukawa@smzkw-mba2023 bin % ./gh codespace ssh
? Choose codespace: shimizukawa/repo (master): repo
Linux codespaces-515b3c 5.15.0-1041-azure #48-Ubuntu SMP Tue Jun 20 20:34:08 UTC 2023 x86_64 The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Sep 28 06:34:19 2023 from 127.0.0.1
@shimizukawa ➜ /workspaces/repo (master) $
ついでに、作る方もghコマンドでやってみました
作成
code:shell
% ./gh codespace create
? Repository: shimizukawa/repo
✓ Codespaces usage for this repository is paid for by shimizukawa
? Branch (leave blank for default branch):
? Choose Machine Type: 4 cores, 16 GB RAM, 32 GB storage (Prebuild ready)
jubilant-spoon-4qvvwppr9cgwg
接続は、起動中でちょっと待たされました
code:shell
% ./gh codespace ssh
? Choose codespace: shimizukawa/repo (master): jubilant spoon
Linux codespaces-fdf976 5.15.0-1041-azure #48-Ubuntu SMP Tue Jun 20 20:34:08 UTC 2023 x86_64 The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
@shimizukawa ➜ /workspaces/repo (master) $