logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

gh-codespace-ssh - SSH into a codespace

Description

       The  ssh  command  is used to SSH into a codespace. In its simplest form, you can run ghcsssh, select a
       codespace interactively, and connect.

       The ssh command will automatically create a public/private ssh key pair in the ~/.ssh directory if you do
       not have an existing valid key pair. When selecting the key pair to use, the preferred order is:

                1. Key specified by -i in <ssh-flags>

                2. Automatic key, if it already exists

                3. First valid key pair in ssh config (according to ssh-G)

                4. Automatic key, newly created

       The ssh command also supports deeper integration with OpenSSH using a --config option that generates per-
       codespace ssh configuration in OpenSSH  format.   Including  this  configuration  in  your  ~/.ssh/config
       improves  the  user  experience  of tools that integrate with OpenSSH, such as Bash/Zsh completion of ssh
       hostnames, remote path completion for scp/rsync/sshfs, git ssh remotes, and so on.

       Once that is set up (see the second example below), you can ssh to codespaces as if  they  were  ordinary
       remote hosts (using ssh, not ghcsssh).

       Note that the codespace you are connecting to must have an SSH server pre-installed.  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"
            }
       }

Example

       $ gh codespace ssh

       $ gh codespace ssh --config > ~/.ssh/codespaces
       $ printf 'Match all\nInclude ~/.ssh/codespaces\n' >> ~/.ssh/config

Name

       gh-codespace-ssh - SSH into a codespace

Options

-c, --codespace<string>
              Name of the codespace

       --config
              Write OpenSSH configuration to stdout

       -d, --debug
              Log debug data to a file

       --debug-file<string>
              Path of the file log to

       --profile<string>
              Name of the SSH profile to use

       -R, --repo<string>
              Filter codespace selection by repository name (user/repo)

       --repo-owner<string>
              Filter codespace selection by repository owner (username or org)

       --server-port<int>(default0)
              SSH server port number (0 => pick unused)

See Also

gh-codespace(1)

                                                    Jan 2025                                 GH-CODESPACE-SSH(1)

Synopsis

ghcodespacessh[<flags>...][--<ssh-flags>...][<command>]

See Also