I need to be able to remotely log into web servers for my clients and edit code remotely. I mostly use this for CSS changes, but also am starting to play with PHP as well.
I have tried to get Remote-Editor to work but it won't pick up the .remote file that I placed in the /home folder. The instructions don't really give great details on setting this up.
What do I do?
Use an FTP client (like FileZilla), then set VSCode as the default editor. Anytime you open a file, it will open it in VSCode. I highly recommend that you download all of the code to your own computer and use it as a dev environment, and then, when you're finished with your changes, backup your site, then upload the modified files together. It's not required to edit files on your own machine, but it is recommended if you ever need to revert to an old version for whatever reason (like you made a mistake in the code, and now nothing works right).
Alternatively, you can use an extension like FTP Sync to code locally, and have the files be automatically synced for you.
There are several approaches to this that are all editor-agnostic.
First, there is sshfs
, which is cross-platform and you can install via your OS package manager. A simple approach would be as following:
mkdir -p ~/mnt/server
sshfs user@server.example.com:/path/on/server ~/mnt/server
Afterwards, you have the complete folder structure from server.example.com
locally available at ~/mnt/server
. Make sure you set up SSH keys to avoid entering the user password every time. You can find tutorials on that everywhere on the net.
For servers that only offer FTP access (shared hosting and the like), you can use curlftpfs
in the same fashion.
To close the connection, simply unmount:
umount ~/mnt
For a GUI-based approach, you have several options. There is Transmit
(macOS), which features mounting connections as volumes, Forklift
(macOS) which is a Finder replacement that can do the same, ExpanDrive
(macOS/Windows) and my favorite Mountain Duck
(macOS/Windows).
If you plan to move lots of data, especially a lot of small files, Mountain Duck performs the best in my experience.
Use FileZilla, then set VScode as default editor (edit->settings->file editing->filetype associations and insert "php /usr/bin/code"). okey, now u need select your file on FTP and press "View/Edit", then ur file open in VScode editor. Done:)