estensione per vs code · gratuitavs code extension · free
Il server
dentro l'editor.The server
inside the editor.
Remote SFTP/FTP porta i server remoti dentro Visual Studio Code: SFTP su SSH, FTP e FTPS, l'albero delle cartelle nella barra laterale, il terminale sulla stessa connessione dei file, la ricerca eseguita sul server. Le password stanno nel portachiavi di sistema, non in un file dentro il progetto. Remote SFTP/FTP brings remote servers inside Visual Studio Code: SFTP over SSH, FTP and FTPS, the folder tree in the sidebar, a terminal on the same connection as the files, search executed on the server. Passwords live in the system keychain, not in a file inside your project.
l'albero remoto nella barra laterale, il file aperto direttamente dal server, la shell sulla stessa connessione. the remote tree in the sidebar, the file opened straight from the server, the shell on the same connection.
Perché l'ho scrittoWhy I wrote it
Da anni sposto file su server remoti mentre sviluppo, e da anni la stessa scena: apri il file con un client FTP, lo modifichi in un editor diverso da quello che stai usando per il progetto, salvi, ricarichi. Oppure installi una delle estensioni per VS Code che fanno la stessa cosa, e scopri che la password del server di produzione è finita in chiaro dentro un file JSON nella cartella del progetto, a un «git add .» di distanza dal repository.
For years I've been moving files onto remote servers while developing, and for years it's been the same scene: you open the file with an FTP client, edit it in an editor that isn't the one you're using for the project, save, reload. Or you install one of the VS Code extensions that do the same thing, and discover that your production password ended up in clear text inside a JSON file in the project folder, one "git add ." away from the repository.
Ho scritto Remote SFTP/FTP per togliermi questo problema, e visto che funziona lo metto a disposizione gratuitamente.
I wrote Remote SFTP/FTP to get that problem off my desk, and since it works, I'm giving it away for free.
Il server diventa parte dell'editorThe server becomes part of the editor
L'idea è semplice. Configuri la connessione una volta, SFTP su SSH oppure FTP e FTPS, e nella barra laterale compare l'albero delle cartelle remote. Clicchi un file, si apre. Lo modifichi, premi Salva, e il file viene riscritto sul server. Non c'è nessuna copia locale che dopo due giorni non sai più se è più aggiornata di quella remota, e non c'è nessuna sincronizzazione da lanciare e da ricordarsi. Una cartella remota può anche diventare la radice del workspace, e a quel punto ci lavori esattamente come su un progetto sul tuo disco.
The idea is simple. You configure the connection once, SFTP over SSH or FTP and FTPS, and the remote folder tree appears in the sidebar. You click a file, it opens. You edit it, hit Save, and the file is written back to the server. There's no local copy that two days later you can't tell is newer or older than the remote one, and there's no sync job to launch and remember. A remote folder can even become the workspace root, and from there you work on it exactly like a project on your own disk.
Terminale, ricerca, trascinamentoTerminal, search, drag and drop
Sulle connessioni SSH c'è anche il terminale remoto, e qui c'è un dettaglio a cui tengo: la shell si apre sulla stessa connessione già aperta per i file. Nessun secondo login, nessuna seconda password. Se lanci il comando da una cartella dell'albero, la shell parte già lì dentro.
On SSH connections there's also the remote terminal, and here's a detail I care about: the shell opens on the same connection already used for the files. No second login, no second password. If you launch the command from a folder in the tree, the shell starts right there.
La funzione che uso di più, però, è la ricerca. Cercare una stringa dentro un progetto su un server remoto è di solito una scocciatura: o scarichi tutto, o entri in SSH e ti arrangi con grep. Qui scegli da quale cartella partire e cosa cercare, e se l'account SSH ha una shell la ricerca viene eseguita direttamente sul server con grep e find. In rete passa solo l'elenco dei risultati, non i file. Clicchi un risultato e il file si apre alla riga giusta. Sulle connessioni FTP, dove una shell non esiste, l'estensione scandaglia le cartelle dal client: più lenta, ma funziona.
The feature I use most, though, is search. Looking for a string inside a project on a remote server is usually a chore: either you download everything, or you log in over SSH and make do with grep. Here you pick which folder to start from and what to look for, and if the SSH account has a shell the search runs directly on the server with grep and find. Only the list of results crosses the network, not the files. You click a result and the file opens at the right line. On FTP connections, where no shell exists, the extension scans the folders from the client: slower, but it works.
Sotto l'albero delle connessioni c'è anche una struttura del file aperto: classi, funzioni e metodi, con un clic per saltarci dentro. Funziona anche sui file remoti il cui linguaggio non ha un language server attivo, grazie a una lettura testuale di riserva.
Below the connections tree there's also an outline of the open file: classes, functions and methods, one click to jump into them. It works on remote files whose language has no active language server too, thanks to a fallback textual scan.
C'è poi tutta la parte di trascinamento. File e cartelle dal gestore file del sistema verso una cartella remota per caricarli, elementi dentro l'albero remoto per spostarli sul server senza far transitare i dati dal tuo computer, e persino fra due connessioni diverse per copiare da un server a un altro: in quel caso i dati passano da un flusso all'altro senza toccare né il disco né la memoria, quindi un file da qualche centinaio di megabyte non è un problema.
Then there's the whole drag and drop side. Files and folders from your system file manager onto a remote folder to upload them, items inside the remote tree to move them on the server without the data travelling through your computer, and even between two different connections to copy from one server to another: in that case the data goes from one stream into the other without touching disk or memory, so a few-hundred-megabyte file is not a problem.
Se usi già altri strumentiIf you already use other tools
Non devi riconfigurare niente a mano: c'è un comando che legge le connessioni dal tuo ~/.ssh/config, dai file sftp.json dei progetti e da un'altra estensione diffusa, ti mostra cosa ha trovato e importa quelle che scegli, unendo i doppioni. Le password e le passphrase che trova finiscono nel portachiavi, non nella configurazione.
You don't have to reconfigure anything by hand: there's a command that reads connections from your ~/.ssh/config, from the projects' sftp.json files and from another widespread extension, shows you what it found and imports the ones you pick, merging duplicates. Passwords and passphrases it finds go into the keychain, not into the configuration.
Sono supportati anche i server raggiungibili solo attraverso un bastione, e se la connessione cade l'operazione in corso viene ripresa da sola: un salvataggio o un trasferimento sopravvivono a un buco di rete senza finestre d'errore.
Servers reachable only through a bastion are supported too, and if the connection drops the operation in flight is retried on its own: a save or a transfer survives a network blip with no error dialogs.
Le tre cose di cui vado più fieroThe three things I'm proudest of
Non si vedono, ed è per quelle che l'ho scritto.You can't see them, and they're the reason I wrote it.
Nel portachiavi, non nel progettoIn the keychain, not in the project
Le password stanno nel portachiavi di sistema, attraverso l'archivio sicuro di VS Code. Non in un file dentro la cartella del progetto, quindi non in un commit per distrazione. Passwords live in the system keychain, through VS Code's secret storage. Not in a file inside the project folder, so not in a commit by accident.
La chiave del server viene verificataThe server key gets verified
Come fa ssh: se l'host è nuovo ti mostra l'impronta e ti chiede conferma; se la chiave è cambiata ti avverte in modo esplicito, perché può essere una rotazione legittima oppure qualcuno in mezzo. Just like ssh does: if the host is new it shows you the fingerprint and asks; if the key changed it warns you explicitly, because that can be a legitimate rotation or someone in the middle.
Niente sovrascritture di nascostoNo silent overwrites
Se un collega ha toccato quel file dopo che l'hai aperto, prima di scrivere ci si ferma: puoi confrontare le due versioni e decidere tu. If a colleague touched that file after you opened it, the save stops before writing: you can compare the two versions and decide for yourself.
Qualche limite, detto subitoA few limits, said up front
- È provata su macOS e Linux; su Windows no.
- It's tested on macOS and Linux; not on Windows.
- I file oltre 16 megabyte non si aprono nell'editor: è un vincolo di VS Code, che riceve i file remoti in un blocco unico. Per quelli conviene usare il download.
- Files over 16 megabytes don't open in the editor: that's a VS Code constraint, it receives remote files as a single block. For those, use the download instead.
- Il terminale SSH aperto non sopravvive a una caduta di connessione e va riaperto.
- An open SSH terminal does not survive a dropped connection and has to be reopened.
- La ricerca nel contenuto su FTP, come dicevo, è più lenta.
- Content search over FTP, as I said, is slower.
Come si installaHow to install
Su macOS e Linux la procedura è la stessa, perché non è un'applicazione del sistema operativo: vive dentro VS Code. Non c'è nessun installer da scaricare, e non serve altro software. Cambia solo il tasto: Cmd sul Mac, Ctrl su Linux. On macOS and Linux the procedure is the same, because this isn't an operating system application: it lives inside VS Code. There's no installer to download, and no other software needed. Only the key changes: Cmd on the Mac, Ctrl on Linux.
Prendi il file .vsixGet the .vsix file
Il pacchetto è remote-sftp-ftp-0.1.0.vsix, e si scarica da questa pagina.
The package is remote-sftp-ftp-0.1.0.vsix, and you download it from this page.
Install from VSIXInstall from VSIX
Apri VS Code e vai nel pannello delle Estensioni, quello con l'icona dei quadratini nella barra laterale, oppure con Cmd+Shift+X su macOS e Ctrl+Shift+X su Linux. In alto a destra di quel pannello c'è un menu con tre puntini: aprilo e scegli «Install from VSIX...», poi seleziona il file che hai appena scaricato.
Open VS Code and go to the Extensions panel, the one with the squares icon in the sidebar, or press Cmd+Shift+X on macOS and Ctrl+Shift+X on Linux. At the top right of that panel there's a three-dots menu: open it and pick "Install from VSIX...", then select the file you just downloaded.
Se preferisci il terminale, c'è la strada breve:
If you prefer the terminal, there's the short way:
Su Linux il comando code di solito è già disponibile. Su macOS va abilitato una volta sola da dentro VS Code: Cmd+Shift+P, poi «Shell Command: Install 'code' command in PATH».
On Linux the code command is usually already available. On macOS you enable it once from inside VS Code: Cmd+Shift+P, then "Shell Command: Install 'code' command in PATH".
Ricarica la finestra e collegatiReload the window and connect
A questo punto ricarica la finestra: Cmd+Shift+P su macOS o Ctrl+Shift+P su Linux, poi scrivi «Reload Window» e invio. Nella barra laterale comparirà una nuova icona, SFTP / FTP. Cliccala e trovi il link per creare la prima connessione.
Now reload the window: Cmd+Shift+P on macOS or Ctrl+Shift+P on Linux, then type "Reload Window" and hit enter. A new icon appears in the sidebar, SFTP / FTP. Click it and you'll find the link to create your first connection.
Serve VS Code 1.85 o successivo. Per aggiornare in futuro basta ripetere la stessa procedura con il file nuovo: la versione precedente viene sostituita, senza doppioni e senza perdere le connessioni configurate, che restano nelle impostazioni di VS Code e nel portachiavi di sistema.
You need VS Code 1.85 or later. To update in future, just repeat the same procedure with the new file: the previous version is replaced, with no duplicates and without losing your configured connections, which stay in VS Code's settings and in the system keychain.
LicenzaLicence
Gratuita per qualunque uso, anche commerciale e in azienda, senza registrazione e senza limiti di tempo o di postazioni. Non è open source. L'unica cosa che chiedo è di non ridistribuire il file altrove: linkate questa pagina, così chi la installa ha sempre la versione corrente.
Free for any use, commercial and inside companies included, with no registration and no limits on time or seats. It is not open source. The only thing I ask is that you don't redistribute the file elsewhere: link this page, so whoever installs it always gets the current version.
Se la provate e trovate qualcosa che non va, scrivetemi.
If you try it and something doesn't work, write to me.