Will it be possible to create an SSH tunnel to a Codespaces instance? #25497
-
For example, to connect via a local terminal, or to use SSHFS for easy access to project files. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 8 replies
-
Hey! This is something we’ve discussed adding support for, and it would be extremely helpful to learn more about your use case. Are you primarily interested in this so that you could use another local desktop app against the files in the Codespace? (e.g. an image editor) |
Beta Was this translation helpful? Give feedback.
-
Yes, for some file types it can be very convenient to use local applications (e.g. Adobe Acrobat DC for browsing/reading PDF files, WinRAR for viewing/unzipping archives, and so on). Quite often you need to quickly move files from the development environment to local storage, and vice versa (Visual Studio Code supports drag-n-drop in the latter case, but the former, as far as I know, is impossible without SSH). Finally, when I was writing this question, the main problem was the need to open HTML files in a browser, which is very easy to do if you use SSHFS. Generally, the problems described can be partially or completely bypassed by using extensions inside the editor, however, these are crutches, and it would be better to have a more natural way of interaction. |
Beta Was this translation helpful? Give feedback.
-
Got it, yeah that makes total sense. Thanks for providing that extra detail! This is something we definitely want to enable, but we don’t have any concrete timelines to share yet. As you said, the current workaround is to leverage an extension that augments the editor for the specific file type you want to manage. For viewing HTML files, you can checkout the Live Server extension and then forward the port that it starts up. Definitely not as smooth as it could be, but maybe enough to unblock you for now? |
Beta Was this translation helpful? Give feedback.
-
Well, I have a slightly different approach to developing in the cloud right now, so it’s no longer a problem. |
Beta Was this translation helpful? Give feedback.
-
You mean you’re no longer using Codespaces? Or that you worked around this limitation in a different way? |
Beta Was this translation helpful? Give feedback.
-
Yes, I don’t use it anymore. This problem is quite important for current projects, so for now, I keep Codespaces a bit on the sidelines. |
Beta Was this translation helpful? Give feedback.
-
UPDATE: You can now set up a connection using the GitHub CLI. See https://docs.github.com/en/codespaces/developing-in-codespaces/using-github-codespaces-with-github-cli#ssh-into-a-codespace and See if this works for you:
The “-o” arguments are optional, but will prevent you from getting warnings or errors about known hosts when you do this from multiple codespaces. Next time you connect, you can spin up the SSH server again by running: EDIT: Note that there is a right-click “Download” option in addition to dragging into the explorer to copy from local, but the script above will let you use SSHFS for local tool access. |
Beta Was this translation helpful? Give feedback.
-
Fantastic! Worked like a charm. Thank you very much, Chuck. |
Beta Was this translation helpful? Give feedback.
-
As a FYI - This script will soon be in the default image for Codespaces. Once that is there, you’ll can just run UPDATE: This is now live. If you type |
Beta Was this translation helpful? Give feedback.
-
How do I SSH into the codespace using SSH command and not gh cs ssh? |
Beta Was this translation helpful? Give feedback.
-
I don't get it, why localhost here |
Beta Was this translation helpful? Give feedback.
UPDATE: You can now set up a connection using the GitHub CLI. See https://docs.github.com/en/codespaces/developing-in-codespaces/using-github-codespaces-with-github-cli#ssh-into-a-codespace and
gh codespace ssh --help
for setup options (like--server-port
to specify a localhost port for use with other ssh clients).See if this works for you: