Agentless SSH
A small, fast SSH file browser for VS Code. Nothing gets installed on the server. It talks plain SFTP, and when you switch user it talks to a POSIX shell.
- No server component. Unlike Remote-SSH, nothing is downloaded to or run on the host. Routers, old boxes and locked-down servers work too.
- Several sessions at once, including several sessions to the same host (for example one as yourself and one as
root).
- Switch user per session. After
sudo or su, the tree lists folders and the editor opens and saves files as that user. Owner and permissions of existing files are kept.
- Uses your
~/.ssh/config (and the system-wide one): Host and Match blocks, HostName, User, Port, IdentityFile, IdentitiesOnly, IdentityAgent, ProxyJump (also chained), ProxyCommand, Include, HostKeyAlias, UserKnownHostsFile, % tokens and ${VAR}.
- ssh-agent, keys (with passphrase), password, keyboard-interactive. Secrets are kept in memory only, so new sessions and reconnects don't ask again. They are forgotten when the last session to that server closes, or with Forget Remembered Passwords.
- Host keys are checked against
known_hosts. An unknown host is confirmed once; a changed key gets a loud warning that lists the keys on record, and @revoked keys are always refused.
Usage
- Open the Agentless SSH view in the activity bar.
- Click a host under Hosts (or use Connect… and type
user@host:port).
- Browse the session under Sessions. Click a file to edit it, then press Cmd/Ctrl+S to save it to the server.
Session actions (inline icons and right-click):
| Action |
What it does |
| Switch User… |
sudo to root or another user, su (with the target user's password), sudo su, or your own command exactly as you type it in a terminal, e.g. sudo -u librenms -i or sudo su - postgres |
| Back to Login User |
Return to plain SFTP as the login user |
| Change Folder… |
Type any path (/etc/nginx, ~/app, ../logs) or pick a recent one |
| Go to Parent / Home |
Quick navigation. Right-click a folder and choose Open as Root Folder to make it the session's root |
| Open Terminal |
Shell on the same connection, as the session's current user, in the selected folder |
| New Session |
Another independent session to the same host |
The status bar shows which user the active remote file will be saved as. Click it to switch user.
Upload, download, drag & drop
|
How |
| Upload |
Drag files or folders from Finder / Explorer / VS Code's Explorer (or an editor tab) onto a folder in Sessions. Or right-click a folder → Upload… |
| Download |
Right-click → Download…. One file asks where to save it. Several items or folders go into a folder you pick |
| Move on the server |
Drag items onto another folder of the same session (asks first) |
| Copy between servers |
Drag items from one session onto a folder of another session. Files are written as that session's user, so you can copy into /root of a sudo session |
| Open |
Drag a remote file onto the editor area |
Select several items with Cmd/Ctrl or Shift; Delete, Download and Copy Path work on all of them. Existing files trigger a Replace / Skip prompt. Files you can't read (or whose names Windows doesn't allow) are skipped and listed at the end, and the rest is still copied. Symlinked folders are not followed.
Dragging files out of the tree to Finder / Explorer / the desktop is not possible: VS Code doesn't let extensions start drags to the operating system. Use Download… instead.
If you get Permission denied, use Switch User…. Open editors keep working and the next save goes through as the new user.
How switching user works
With Your own command… Agentless SSH runs the command you'd type in a terminal (for example sudo -u librenms -i), answers its password prompt with what you type in VS Code, and then starts its helper inside the shell that opens. This also works when the user's login profile starts yet another shell.
Agentless SSH runs sudo -u <user> /bin/sh (or su -s /bin/sh <user>) on a pseudo-terminal of the existing connection. If a password is asked, you type it in VS Code's input box. The terminal is then switched to raw mode, and file operations are done with standard tools (stat, base64, dd, cat, mkdir, mv, rm). These are present on GNU/Linux, BusyBox and BSD/macOS systems. A command takes well under a millisecond on top of the network round trip.
Files larger than 32 KB are saved through a faster path. The login user uploads them over SFTP into /tmp/.agentless-ssh-<random> (mode 0711, so other users can't list it), under a random name. The other user's shell then copies the data into place with cat, and the temp file is deleted right away.
Saving never risks the old content. An existing file is written in place, so it keeps its owner, permissions, hard links and ACLs, but only once a copy of its current content exists:
- over SFTP the old content is kept in memory (or a local temp file for files over 64 MB), the part beyond the old end is written first (a full disk or quota fails before anything old is overwritten), and if writing fails the old content is put back;
- as another user, the new content and a copy of the old one are first written to temp files next to the file (or in
/tmp); no space for them means nothing is changed, and if the final copy fails the old content is put back.
If even putting it back fails (for example the connection was lost), the error says where the previous content was saved. New files are created exclusively, so a file that appears meanwhile is never overwritten. Renaming onto an existing name moves the old item aside and puts it back if the move fails.
Commands are pipelined (several in flight), so browsing as another user costs about one network round trip per folder. Data read through the shell is checked, so a terminal broadcast (wall, shutdown notices) can't silently corrupt a file.
Windows, macOS, Linux
The extension is pure JavaScript (no native modules), so it runs the same on all three.
- SSH config and keys are read from
~/.ssh (%USERPROFILE%\.ssh on Windows).
- ssh-agent:
IdentityAgent from the config, otherwise SSH_AUTH_SOCK. On Windows without SSH_AUTH_SOCK, the built-in OpenSSH Authentication Agent service is tried first, then Pageant (PuTTY). If no agent is running, Agentless SSH moves on to key files and passwords.
Security notes
- File names come from the server and are never trusted: names with
/, .. or characters Windows forbids are refused on download, and paths are passed to the server only as quoted data.
- The connection settings (
agentlessSsh.hosts, agentlessSsh.sshConfigPath, agentlessSsh.importSshConfig) can only be set in your user settings, not by a workspace's .vscode/settings.json.
Settings
| Setting |
Default |
|
agentlessSsh.hosts |
[] |
Extra hosts: { "name", "host", "port", "user", "identityFile", "proxyJump", "folder" } |
agentlessSsh.importSshConfig |
true |
Show hosts from the SSH config |
agentlessSsh.sshConfigPath |
"" |
Custom SSH config path |
agentlessSsh.showHiddenFiles |
true |
Show dot files |
Development
npm install
npm run build # bundle to dist/extension.js
npm run typecheck
npx vsce package # -> agentless-ssh-<version>.vsix
Press F5 in VS Code to run the extension in a development host. test/run.sh runs the integration tests against throwaway sshd containers (Docker).