Run VS Code on any server over SSH.

Related tags

DevOps Tools sshcode
Overview

sshcode

This project has been deprecated in favour of the code-server install script

See the discussion in #185


"Open Issues" "Latest Release" MIT license Discord Build Status

sshcode is a CLI to automatically install and run code-server over SSH.

It uploads your extensions and settings automatically, so you can seamlessly use remote servers as VS Code hosts.

If you have Chrome installed, it opens the browser in app mode. That means there's no keybind conflicts, address bar, or indication that you're coding within a browser. It feels just like native VS Code.

Demo

Install

Have Chrome installed for the best experience.

Install with go:

go get -u go.coder.com/sshcode

Or, grab a pre-built binary.

OS Support

We currently support:

  • Linux
  • MacOS
  • WSL

For the remote server, we currently only support Linux x86_64 (64-bit) servers with glibc. musl libc (which is most notably used by Alpine Linux) is currently not supported on the remote server: #122.

Usage

sshcode [email protected]
# Starts code-server on dev.kwc.io and opens in a new browser window.

You can specify a remote directory as the second argument:

sshcode [email protected] "~/projects/sourcegraph"

Extensions & Settings Sync

By default, sshcode will rsync your local VS Code settings and extensions to the remote server every time you connect.

This operation may take a while on a slow connections, but will be fast on follow-up connections to the same server.

To disable this feature entirely, pass the --skipsync flag.

Custom settings directories

If you're using an alternate release of VS Code such as VS Code Insiders, you must specify your settings directories through the VSCODE_CONFIG_DIR and VSCODE_EXTENSIONS_DIR environment variables.

The following will make sshcode work with VS Code Insiders:

MacOS

export VSCODE_CONFIG_DIR="$HOME/Library/Application Support/Code - Insiders/User"
export VSCODE_EXTENSIONS_DIR="$HOME/.vscode-insiders/extensions"

Linux

export VSCODE_CONFIG_DIR="$HOME/.config/Code - Insiders/User"
export VSCODE_EXTENSIONS_DIR="$HOME/.vscode-insiders/extensions"

Sync-back

By default, VS Code changes on the remote server won't be synced back when the connection closes. To synchronize back to local when the connection ends, pass the -b flag.

Issues
  • MSYS/MINGW Client Support (FINNALLY Working)

    MSYS/MINGW Client Support (FINNALLY Working)

    EDIT: OLD IMAGES HAVE BEEN REDUCED TO LINKS TO SAVE POST SPACE

    Basically, I have made sshcode run properly on msys/mingw enviroments,

    TL;DR

    • Chrome only works when using msys/cygwin based enviroments
    • sshcode only works in msys/cygwin based enviroments
    • sshcode in cmd.exe does not work yet due to how sshcode calls ssh

    Summary of my edits

    • main.go > Added filepath conversion, (thanks @eargollo )
    • settings.go > added default paths for VSCode data on windows
    • sshcode.go > copied and slightly tweaked the wslPath to match a windows enviroment for accessing the C:\ drive.

    TODO

    • 100% windows support: NOTE, I do not plan on implementing this for the time being, i feel like i have dont enought to make a great step towards windows support, this todo will be a log of the errors in windows
      • Some odd bug where it returns this when running with cmd.exe
      • The error appears to be sshcode not actually executing ssh on windows even if it is in %path%
        • This appears to be because of how sshcode calls the ssh command
    C:\Misc\MegaSync\Code\Workspace\sshcode>go build
    
    C:\Misc\MegaSync\Code\Workspace\sshcode>sshcode.exe --skipsync [email protected]
    2019-07-29 20:58:13 INFO       failed to stat ~/.ssh directory, disabling connection reuse feature: CreateFile ~\.ssh: The system cannot find the path specified.
    2019-07-29 20:58:13 INFO       ensuring code-server is updated...
    2019-07-29 20:58:13 FATAL      error: failed to update code-server:
    ---ssh cmd---
    ssh  [email protected] '/usr/bin/env bash -l'
    ---download script---
    set -euxo pipefail || exit 1
    
    [ "$(uname -m)" != "x86_64" ] && echo "Unsupported server architecture $(uname -m). code-server only has releases for x86_64 systems." && exit 1
    pkill -f ~/.cache/sshcode/sshcode-server || true
    mkdir -p ~/.local/share/code-server ~\.cache\sshcode
    cd ~\.cache\sshcode
    curlflags="-o latest-linux"
    if [ -f latest-linux ]; then
            curlflags="$curlflags -z latest-linux"
    fi
    curl $curlflags https://codesrv-ci.cdr.sh/latest-linux
    [ -f ~/.cache/sshcode/sshcode-server ] && rm ~/.cache/sshcode/sshcode-server
    ln latest-linux ~/.cache/sshcode/sshcode-server
    chmod +x ~/.cache/sshcode/sshcode-server: exec: "sh": executable file not found in %PATH%
    

    attached image is of it building and running (first working release,) https://user-images.githubusercontent.com/10422110/61765201-ef1c0e80-ad90-11e9-87cb-b46e6dc2a909.gif

    This image is of the second build working just fine, Note, yes i did have to drag the window over from the side, that is because i have two monitors, and for some reason my mouse wasnt recorded so... thats a thing https://user-images.githubusercontent.com/10422110/62153007-8533c580-b2b8-11e9-9d2b-03e25af9bbd0.gif

    8-9-2019, 1211 -7PST This build has the sshMaster fix (i didnt bother building it again just for the example as it would take FOREVER as seen in previous pictures, and sorry for horrible quality,) https://user-images.githubusercontent.com/10422110/62803352-094b3180-ba9f-11e9-818f-4c4b93fb60ed.gif

    8-9-2019, 1308 -7PST this build is a work in progress, some users may have to modify main.go to match their setups. otherwise sshcode --skipsync [email protected] /<choosen filepath> works. In the example i open /opt on the server https://user-images.githubusercontent.com/10422110/62806173-f50b3280-baa6-11e9-8438-71a5aa6d7104.gif

    8-9-2019, 1358 -7PST Not going to upload gif, would take to long, but rsync now works provided its installed and in path UPDATE: DESPITE WHAT TRAVIS SAYS, IT WORKS, AND BUILDS JUST FINE

    opened by Merith-TK 24
  • GitBash and MinGW support

    GitBash and MinGW support

    TL;DR

    • cmd.exe is not supported, please use git4win or msys2
    • Rewrote PR from #127
    • Fixed a ghost path creation error in ensureDir()

    Summary of Edits

    • Fixed file pathing for windows client
    • Fixed ghost path creation on windows client
    • Added check to fix variables when using windows clients

    Progress

    Latest Build:

    • Resolving paths is now fully functional.
    • Ghost paths are no longer created on the client, (bug with patches to ensureDir()
    • The following formats now work for opening remote paths, /Workspace, Workspace, ~/Workspace, Workspace/
    • Code cleanup
    opened by Merith-TK 20
  • Cannot use from Android Termux

    Cannot use from Android Termux

    Now, I decided to be unorthodox here and successfully compiled the go binary for Termux on android 8.1

    When i try and run on my server (which sucessfully runs cdr/code-server ) it returns an error that the android platform is not supported

    $ sshcode [email protected] -b
    2019-05-22 02:16:58 INFO        ensuring code-server is updated...
    [email protected]'s password:
    + pkill -f /home/merith/.cache/sshcode/sshcode-server
    + true
    + mkdir -p /home/merith/.local/share/code-server /home/merith/.cache/sshcode
    + cd /home/merith/.cache/sshcode
    + wget -N https://codesrv-ci.cdr.sh/latest-linux
    --2019-05-21 19:17:19--  https://codesrv-ci.cdr.sh/latest-linux
    Resolving codesrv-ci.cdr.sh (codesrv-ci.cdr.sh)... 104.27.132.26, 104.27.133.26, 2606:4700:30::681b:851a, ...
    Connecting to codesrv-ci.cdr.sh (codesrv-ci.cdr.sh)|104.27.132.26|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 94698820 (90M) [application/octet-stream]
    Saving to: ‘latest-linux’
    
     92450K .......... .......... .........                       100% 12.7M=90s
    
    2019-05-21 19:18:50 (1.00 MB/s) - ‘latest-linux’ saved [94698820/94698820]
    
    + '[' -f /home/merith/.cache/sshcode/sshcode-server ']'
    + ln latest-linux /home/merith/.cache/sshcode/sshcode-server
    + chmod +x /home/merith/.cache/sshcode/sshcode-server
    2019-05-22 02:18:32 INFO        syncing settings
    2019-05-22 02:18:32 FATAL       error: failed to sync settings: unsupported platform: android
    

    ^pastebin^

    opened by Merith-TK 15
  • Add SSH master connection feature

    Add SSH master connection feature

    By default, sshcode will now start a master connection with no command so that users only need to authenticate once and multiple connections don't need to be established. This speeds up load times significantly as there are less handshakes required. Currently, it requires you to enter your password or SSH key passphrase 4 times (6 times with sync back) unless you are using an agent.

    To disable the added behaviour you can use --no-reuse-connection.

    You can do this now on the current sshcode version by doing --ssh-flags '-o "ControlPath=/tmp/test" -o "ControlMaster=auto" -o "ControlPersist=5m"', but this will keep SSH connections open after sshcode exits which likely isn't desired.

    Closes #115.

    TODO:

    • [ ] Test in more environments
    • [x] Make checkSSHMaster() also check if the master process is dead in check
    • [x] Automatically disable if ~/.ssh doesn't exist (and maybe if it's permissions aren't safe)
    opened by deansheather 13
  • 2 instances of sshcode (same machine / same remote user) => WebSocket closed

    2 instances of sshcode (same machine / same remote user) => WebSocket closed

    This problem exists with the last version of sshcode (v0.7 I think) that lives in a user local dir on the remote machine.

    If you launch sshcode twice from the same local machine and user to the same remote machine and user, the second instance will disconnect the first one. There can be only one instance running on the server. It used to work well with multiple instances when sshcode was running from the /tmp dir, I do not know how to fix it, but it is a problem since I often work on multiple projects on the same server and I do not want to open only one instance containing all my projects since it will slow down search operations, etc. Is it a know problem? Is there any workaround or possible fix?

    opened by badaz 13
  • Unable to install sshcode on  MacOS

    Unable to install sshcode on MacOS

    Hi,

    I'm trying to install sshcode on my MacBook using command 'go get -u go.coder.com/sshcode'. It is failing to install sshcode without displaying any error or progress message.

    Can anyone please help me to install sshcode on MacOS?

    Thanks, Suheel

    opened by suheelsn 12
  • fix #167 use latest version of code-server

    fix #167 use latest version of code-server

    Hello!

    This PR fixes https://github.com/cdr/sshcode/issues/167

    There was a bit of a jungle with https://github.com/cdr/sshcode/pull/178 and https://github.com/cdr/sshcode/pull/181, so let me explain what happened.

    Big thanks to @Merith-TK I realized, that the different PR order would make more sense. However we misunderstood each other a bit with the PR openings. Anyway - everything is clear now, so I am making the PRs in the right order. My apologies for the PR jungling :)

    opened by gyzerok 11
  • code-server is not being updated to the latest version

    code-server is not being updated to the latest version

    Using sshcode v0.7.0 the logs show:

    INFO  code-server v1.939-vsc1.33.1
    

    The latest version of code-server at time of writing is 1.1119-vsc1.33.1. It appears that https://codesrv-ci.cdr.sh/latest-linux isn't updated with the latest release.

    opened by maxfi 10
  • Incompatible with wget from BusyBox

    Incompatible with wget from BusyBox

    Trying to use this against my Alpine Linux server, but receive the following error:

    2019-05-12 15:07:05 INFO	ensuring code-server is updated...
    + mkdir -p /home/steve/.local/share/code-server
    + cd /tmp
    + wget -N https://codesrv-ci.cdr.sh/latest-linux
    wget: unrecognized option: N
    BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.
    
    Usage: wget [-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]
    	[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
    	[-S|--server-response] [-U|--user-agent AGENT] [-T SEC] URL...
    
    Retrieve files via HTTP or FTP
    
    	--spider	Only check URL existence: $? is 0 if exists
    	-c		Continue retrieval of aborted transfer
    	-q		Quiet
    	-P DIR		Save to DIR (default .)
    	-S    		Show server response
    	-T SEC		Network read timeout is SEC seconds
    	-O FILE		Save to FILE ('-' for stdout)
    	-U STR		Use STR for User-Agent header
    	-Y on/off	Use proxy
    2019-05-12 15:07:06 FATAL	failed to update code-server: exit status 1
    ---ssh cmd---
    ssh  [email protected] /bin/bash
    ---download script---
    set -euxo pipefail || exit 1
    
    mkdir -p ~/.local/share/code-server
    cd /tmp
    wget -N https://codesrv-ci.cdr.sh/latest-linux
    [ -f /tmp/codessh-code-server ] && rm /tmp/codessh-code-server
    ln latest-linux /tmp/codessh-code-server
    chmod +x /tmp/codessh-code-server
    

    It looks like alpine uses a different wget version, any way to detect and fix this?

    Thanks

    opened by SteveEdson 10
  • error: failed to parse host IP: host argument is not a valid IP address

    error: failed to parse host IP: host argument is not a valid IP address

    Hello

    I've just installed sshcode, using go get -u go.coder.com/sshcode, and go to run it, and it fails with the below error:

    sshcode [email protected]
    2019-05-02 11:13:06 INFO	ensuring code-server is updated...
    2019-05-02 11:13:06 FATAL	error: failed to parse host IP: host argument is not a valid IP address
    

    Does it only work with ip addresses?

    I'm running sshcode on Ubuntu 19.04.

    opened by magick93 10
  • Non standard ssh port not working

    Non standard ssh port not working

    Tried to specify a different port for ssh on my server
    sshcode [email protected]:port returns error sshcode [email protected] --ssh-flags '-p xxxx' is ignored

    How should it be done?

    opened by sladec 9
  • Hold on any future development

    Hold on any future development

    I've written a shell script in /bin/sh to automatically and correctly install code-server on any MacOS and Linux system.

    It'll be in the main code-server repo.

    See https://github.com/cdr/code-server/pull/1701

    At the moment it does not support installing over ssh but it will soon and the plan is for it to replace and deprecate sshcode as something we'll maintain alongside code-server.

    Please let me know your thoughts in this issue.

    opened by nhooyr 37
  • sshode sems to be messing with chrome settings

    sshode sems to be messing with chrome settings

    If I open chrome while sshcode is running all my extensions disappear, for them to re-appear I need to close sshcode and all instances of chrome then they just appear again.

    I'm on windows 10 Pro Build 18362

    Running sshcode through Ubuntu 20.04 through WSL

    opened by williamjohnstone 3
  • [MSYS BUG][Reason Discovered] ~ is resolved to msys home instead of remote home

    [MSYS BUG][Reason Discovered] ~ is resolved to msys home instead of remote home

    NOTICE: This first post is for when using sshcode [email protected] ~/X paths,

    DISCLAIMER: This example was shown to affect both sshcode 10 builds and custom builds that use code-server 3.X

    When you feed sshcode ~/ instead of "~/", it will attempt to use the local ~/ path. for example if your user is merith and the remote user is developer when you feed sshcode ~/Workspace it will attempt to open /home/merith/Workspace instead of /home/developer/Workspace

    output from a shell giving this error

    2020-05-11 12:26:24 ←[94mINFO←[0m       OS is windows, disabling connection reuse feature
    2020-05-11 12:26:24 ←[94mINFO←[0m       ensuring code-server is updated...
    ++ uname -m
    + '[' x86_64 '!=' x86_64 ']'
    + pkill -f /home/developer/.sshcode-server
    + true
    + mkdir -p /home/developer/.sshcode-server
    + cd /home/developer/.sshcode-server
    + '[' '!' -d code-server-3.2.0-linux-x86_64 ']'
    2020-05-11 12:26:27 ←[94mINFO←[0m       starting code-server...
    2020-05-11 12:26:27 ←[94mINFO←[0m       Tunneling remote port 33885 to 127.0.0.1:24586
    info  code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f
    info  HTTP server listening on http://127.0.0.1:33885
    info    - No authentication
    info    - Not serving HTTPS
    info  Automatic updates are enabled
    warn  ENOENT: no such file or directory, stat '/home/Merith/Workspace'
    warn  ENOENT: no such file or directory, stat '/home/Merith/Workspace'
    

    What fixes this.

    These work

    sshcode [email protected] "~/Workspace"
    sshcode [email protected] \~/Workspace
    sshcode [email protected] Workspace
    sshcode [email protected] /opt/Workspace
    sshcode [email protected] /home/user/Workspace
    

    This dont work

    sshcode [email protected] ~/Workspace

    opened by Merith-TK 1
  • Remote directory argument is not working

    Remote directory argument is not working

    I successfully installed sshcode and it is running perfectly, except the remote directory argument is not working as expected. For example if I run the following it always starts the sshcode from remote server home directory (~/), i.e. sshcode ignores the second remote directory argument. sshcode [email protected] "~/projects/sourcegraph"

    Did I need to configure anything after installing sshcode?

    opened by mmiakashs 3
Releases(v0.10.0)
Owner
Coder
We make it easy to write more code.
Coder
Integrated ssh-agent for windows. (pageant compatible. openSSH ssh-agent etc ..)

OmniSSHAgent About The chaotic windows ssh-agent has been integrated into one program. Chaos Map of SSH-Agent on Windows There are several different c

YAMASAKI Masahide 28 Aug 14, 2022
easy way to distribute commands over ssh.

grapes grapes is lightweight tool designed to distribute commands over ssh with ease. Update (25/04/2019) Handshake validation is now in place in orde

Yaron Sumel 156 Jun 16, 2022
Dominik Robert 0 Jan 4, 2022
⚡️ A dev tool for microservice developers to run local applications and/or forward others from/to Kubernetes SSH or TCP

Your new microservice development environment friend. This CLI tool allows you to define a configuration to work with both local applications (Go, Nod

Vincent Composieux 1.3k Aug 4, 2022
A tool to build, deploy, and release any application on any platform.

Waypoint Website: https://www.waypointproject.io Tutorials: HashiCorp Learn Forum: Discuss Waypoint allows developers to define their application buil

HashiCorp 4.5k Aug 9, 2022
sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC), and Everything as Code. So it is a tool for DevOps.

sail 中文文档 sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC),a

Bougou Nisou 10 Dec 16, 2021
Open Source runtime tool which help to detect malware code execution and run time mis-configuration change on a kubernetes cluster

Kube-Knark Project Trace your kubernetes runtime !! Kube-Knark is an open source tracer uses pcap & ebpf technology to perform runtime tracing on a de

Chen Keinan 31 Jul 27, 2022
A Friendly SSH Jumper Bastion Fortress Server

Felix 中文 Thanks to 360 Total Security and 360-web-platform For Whom BackEnd Engineer Golang SQL RESTful APIs engineer DevOps Engineer People Heavily e

mojocn 711 Aug 8, 2022
A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file.

A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file. This application is intend for non tecnhincal users they can just open the GUI and given the server details just deploy.

Jobin Jose 1 Oct 16, 2021
webhook is a lightweight incoming webhook server to run shell commands

What is webhook? webhook is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, whi

Adnan Hajdarević 8k Aug 10, 2022
ginko-volkswagen detects when your tests are being run in a CI server, and reports them as passing

detects when your ginkgo-based tests are being run in a CI server, and reports them as passing

Christoph Blecker 7 Dec 4, 2021
Boxygen is a container as code framework that allows you to build container images from code

Boxygen is a container as code framework that allows you to build container images from code, allowing integration of container image builds into other tooling such as servers or CLI tooling.

nitric 5 Dec 13, 2021
Copy files and artifacts via SSH using a binary, docker or Drone CI.

drone-scp Copy files and artifacts via SSH using a binary, docker or Drone CI. Feature Support routines. Support wildcard pattern on source list. Supp

Bo-Yi Wu 108 Jul 22, 2022
easyssh-proxy provides a simple implementation of some SSH protocol features in Go

easyssh-proxy easyssh-proxy provides a simple implementation of some SSH protocol features in Go. Feature This project is forked from easyssh but add

Bo-Yi Wu 251 Jul 31, 2022
Manage your ssh alias configs easily.

manssh manssh is a command line tool for managing your ssh alias config easily, inspired by storm project, powered by Go. Note: This project is actual

Wendell Sun 268 Aug 9, 2022
A simple and powerful SSH keys manager

SKM is a simple and powerful SSH Keys Manager. It helps you to manage your multiple SSH keys easily! Features Create, List, Delete your SSH key(s) Man

Timothy 791 Aug 9, 2022
Open URL in your local web browser from the SSH-connected remote environment.

opener Open URL in your local web browser from the SSH-connected remote environment. How does opener work? opener is a daemon process that runs locall

Kazuki Suda 55 Jun 29, 2022
Google Compute Engine (GCE) VM takeover via DHCP flood - gain root access by getting SSH keys added by google_guest_agent

Abstract This is an advisory about an unpatched vulnerability (at time of publishing this repo, 2021-06-25) affecting virtual machines in Google's Com

null 517 Aug 11, 2022
go-awssh is a developer tool to make your SSH to AWS EC2 instances easy.

Describing Instances/VPCs data, select one or multiple instances, and make connection(s) to selected instances. Caching the response of API calls for 1day using Tmpfs.

kenju 5 Oct 11, 2021