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       The  'ssh'  command  will automatically create a public/private ssh key
22       pair in the ~/.ssh directory if you do not have an existing  valid  key
23       pair. When selecting the key pair to use, the preferred order is:
24
25
26                1. Key specified by -i in
27
28                2. Automatic key, if it already exists
29
30                3. First valid key pair in ssh config (according to ssh -G)
31
32                4. Automatic key, newly created
33
34
35
36       The 'ssh' command also supports deeper integration with OpenSSH using a
37       '--config' option that generates  per-codespace  ssh  configuration  in
38       OpenSSH format.  Including this configuration in your ~/.ssh/config im‐
39       proves the user experience of tools that integrate with  OpenSSH,  such
40       as  bash/zsh  completion  of  ssh hostnames, remote path completion for
41       scp/rsync/sshfs, git ssh remotes, and so on.
42
43
44       Once that is set up (see the second example  below),  you  can  ssh  to
45       codespaces  as if they were ordinary remote hosts (using 'ssh', not 'gh
46       cs ssh').
47
48
49       Note that the codespace you are connecting to must have an  SSH  server
50       pre-installed.   If  the docker image being used for the codespace does
51       not have  an  SSH  server,  install  it  in  your  Dockerfile  or,  for
52       codespaces  that  use Debian-based images, you can add the following to
53       your devcontainer.json:
54
55
56       "features":    {         "ghcr.io/devcontainers/features/sshd:1":     {
57                 "version": "latest"      } }
58
59
60

OPTIONS

62       -c, --codespace <string>
63              Name of the codespace
64
65
66       --config
67              Write OpenSSH configuration to stdout
68
69
70       -d, --debug
71              Log debug data to a file
72
73
74       --debug-file <string>
75              Path of the file log to
76
77
78       --profile <string>
79              Name of the SSH profile to use
80
81
82       -R, --repo <string>
83              Filter codespace selection by repository name (user/repo)
84
85
86       --repo-owner <string>
87              Filter codespace selection by repository owner (username or org)
88
89
90       --server-port <int>
91              SSH server port number (0 => pick unused)
92
93
94

EXAMPLE

96       $ gh codespace ssh
97
98       $ gh codespace ssh --config > ~/.ssh/codespaces
99       $ printf 'Match all\nInclude ~/.ssh/codespaces\n' >> ~/.ssh/config
100
101
102
103
104

SEE ALSO

106       gh-codespace(1)
107
108
109
110                                   Nov 2023                GH-CODESPACE-SSH(1)
Impressum