1GH-CODESPACE-SSH(1)            GitHub CLI manual           GH-CODESPACE-SSH(1)
2
3
4

NAME

6       gh-codespace-ssh - SSH into a codespace
7
8
9

SYNOPSIS

11       gh codespace ssh [<flags>...] [-- <ssh-flags>...] [<command>]
12
13
14

DESCRIPTION

16       The  'ssh'  command  is  used  to SSH into a codespace. In its simplest
17       form, you can run 'gh cs ssh', select a  codespace  interactively,  and
18       connect.
19
20
21       By default, the 'ssh' command will create a public/private ssh key pair
22       to
23       authenticate with the codespace inside the ~/.ssh directory.
24
25
26       The 'ssh' command also supports deeper integration with OpenSSH using a
27       '--config'  option  that  generates  per-codespace ssh configuration in
28       OpenSSH format.  Including this configuration in your ~/.ssh/config im‐
29       proves  the  user experience of tools that integrate with OpenSSH, such
30       as bash/zsh completion of ssh hostnames,  remote  path  completion  for
31       scp/rsync/sshfs, git ssh remotes, and so on.
32
33
34       Once  that  is  set  up  (see the second example below), you can ssh to
35       codespaces as if they were ordinary remote hosts (using 'ssh', not  'gh
36       cs ssh').
37
38
39       Note  that  the codespace you are connecting to must have an SSH server
40       pre-installed.  If the docker image being used for the  codespace  does
41       not  have  an  SSH  server,  install  it  in  your  Dockerfile  or, for
42       codespaces that use Debian-based images, you can add the  following  to
43       your devcontainer.json:
44
45
46       "features":     {         "ghcr.io/devcontainers/features/sshd:1":    {
47                 "version": "latest"      } }
48
49
50

OPTIONS

52       -c, --codespace <string>
53              Name of the codespace
54
55
56       --config
57              Write OpenSSH configuration to stdout
58
59
60       -d, --debug
61              Log debug data to a file
62
63
64       --debug-file <string>
65              Path of the file log to
66
67
68       --profile <string>
69              Name of the SSH profile to use
70
71
72       --server-port <int>
73              SSH server port number (0 => pick unused)
74
75
76

EXAMPLE

78              $ gh codespace ssh
79
80              $ gh codespace ssh --config > ~/.ssh/codespaces
81              $ printf 'Match all\nInclude ~/.ssh/codespaces\n' >> ~/.ssh/config
82
83
84
85
86

SEE ALSO

88       gh-codespace(1)
89
90
91
92                                   Jan 2023                GH-CODESPACE-SSH(1)
Impressum