FTP/SSH Bundle for TextMate

(Download link at the bottom)

Since you are reading this you probably know there is no build-in FTP/SSH support in TextMate.
This bundle tries to work around this a little bit. Not satisfied by the perfomance of solutions like Macfusion or Expandrive I choosed to develop my own solution.

Using the FTP/SSH bundle you may be able to download (reload) and upload files to a remote host using FTP or SSH. You always work on a local copy of the remote files. Remote files must be downloaded first by another method and manually added to your TextMate Project file. You may use the FTP/SSH bundle for TextMate Projects or just single files.

Warning

This Bundle manipulates and overwrites local and remote files without prompting. Although I took care when creating this bundle I don't give a guarantee for its proper function. Use it on your own risk.

Remote Connection settings

The FTP/SSH bundle get its remote connection settings from a file called .ftpssh_settings. This file must be located in the same directory where your TextMate Project file is saved. If you don’t use a TextMate Project but single files you must place the .ftpssh_settings file at the same directory level where your single files are saved.

Use the FTP/SSH command Remote Connection Settings… to enter connection parameters for remote FTP or SSH servers. It will take care of where to save .ftpssh_settings.

These are the parameters to be used in .ftpssh_settings or entered using the Remote Connection Settings… command. All except cli_options and password (FTP only) are mandantory.

  • protocol: SSH or FTP
  • user: Login name on the remote host
  • password: Password to login on the remote host (FTP only)
  • host: Name or IP of the remote host
  • path: Relative (to $HOME) or absolute path of your project on the remote host
  • cli_options: Command line options/arguments for /usr/bin/ftp or /usr/bin/scp (optional)

Note: Because SSH does not support passwords on the command line it only works if you set up passwordless authentication like Public key authentication. See the SSH manual for how to do this.
Note 2: Passwords for FTP are saved in clear text. To secure it a little bit the .ftpssh_settings file will be set to file mode 0600 (read/write only by the owner).

Format of .ftpssh_settings file

Example .ftpssh_settings for a FTP connection:


protocol = ftp
user = username
password = password
host = myserver.com
path = path/to/remote_project
cli_options =

Example .ftpssh_settings for a SSH connection:


protocol = ssh
user = username
password =
host = myserver.com
path = path/to/remote_project
cli_options = -C

(Compression of data transfer enabled by cli_options = -C)

Using FTP/SSH commands

The FTP/SSH bundle commands works on the current window (open file) only. It’s not possible to reload or save all files in a TextMate Project at once.

  • Reload Remote File
    To get the latest revision of a remote file use this command. This will overwrite the local file.
    Shortcut: alt-R

  • Upload File
    Save local changes to the remote host (and the local file). This will overwrite the remote file.
    Shortcut: alt-S

  • Remote Connection Settings…
    Edit and save remote connection parameters for remote FTP or SSH servers.

  • Help
    Show Help.

There is no fancy response sign (spinning wheel, progress bar) during data transfer. After success or failure of the commands you get a message as tool tip or - if installed - via Growlnotify.

TODO

  • Reload all files of a TextMate Project at once
  • Upload all changed files of a TextMate Project at once
  • Show diffs between local and remote files

CHANGELOG

v2.3 (2008-05-13)

  • FIXED: Error when loading connection setting parameters which contains non-alphanumeric characters. (Thanks to Jonas Grau).
  • FIXED: Chopping off the first character from the file path in some circumstances will not occure anymore. (Thanks Jason).
  • FIXED: All error output from /usr/bin/ftp and /usr/bin/scp is catched
  • CHANGED: Uploading and reloading of files is more robust because (1) the local file will be addressed using it's absolute path and (2) the arguments to the SCP and FTP commands are escaped for all kinds of file or path names (hopefully).
  • CHANGED: In case of error the executed FTP or SCP command line will be displyed for better error checking. (Tip: Go to Bundles > Bundle Editor, open the FTP/SSH Bundle, select the "Upload" or "Reload" command and choose "Create New Document" as Output option. This way you can copy the command line used by the FTP/SSH Bundle and try it in a Terminal Shell.)

v2.2 (2007-12-29)

  • FIXED: Command "Remote Connection Settings..." missing. (Thanks to Russ Brooks).

Suggestions welcome! Write to bernhard@fuersten.info or drop a commentar at http://fuerstnet.de/ftp-ssh-bundle-textmate.

AttachmentSize
FTP_SSH_v2.3.tmbundle.zip19.22 KB

Comments

Great bundle as I have been

Great bundle as I have been looking for a decent solution to the lack of ftp/ssh support in textmate. I ran into one small problem though, apparently lines 36 & 81 were chopping off a character of the root filename:

$relative_dir = substr($TM_DIRECTORY, strlen((empty($PROJECT_DIR) ? $TM_DIRECTORY : $PROJECT_DIR))+1);

My root file folder is /fm and it would give me the error that it cannot open directory: /m/pages/myfile.html instead of /fm/pages/myfile.html.

Anyway I fixed the problem by removing the +1 on those lines.

Again thanks for a great bundle.

~Jason

Character chopping fixed in v2.3

The 1 character chopping off from the file path is fixed in v2.3 by changing how the $relative_dir is determined.

Line 36 and line 79 seem to

Line 36 and line 79 seem to rewrite the $relative_dir weirdly if the .tmproj file isn't in the same directory as the project files. I started to fix it, but decided it'd be easier to just stick the .tmproj in with the project.

The TM Project file

The TM Project file (.tmproj) must be saved in the root of your project directory. If not the FTP/SSH Bundle can't determine the directory path your files belong to in relation to the remote project root.

If a file is outside of the TM Project file path it is uploaded to the root of the remote path you set in the Remote Connection Settings dialog as of v2.3 of FTP/SSH Bundle.

Brilliant bundle - saved me

Brilliant bundle - saved me hours and hours. Particularly appreciate its simplicity - it only does one thing, but it does it well! Love it!

Incredible. Thanks so much

Incredible. Thanks so much for your work on this. This is really going to streamline my development.

FTP-SSH Bundle totally rocks...

I switched to TextMate from Dreamweaver almost 2 years ago and FTP management has been the only thing I missed. This bundle is fantastic thanks so much.

TextMate + ProjectPlus + FTP-SSH totally rocks.

steve www.squarehead.com

how to configure ftp access

how to configure ftp access to dedicated server ?

e texeditor

could you give us the e texeditor (windows) version of the bundle ?

none

just wanna say that this bundle is incompatible with e texteditor there's probably a simple fix to port it it would be great... cause -remote project- doesn't have -upload file-

No Windows port from my side

I don't know about Windows and FTP or SSH commands available there so I'm sorry - I will not do a Windows port of this bundle.

Saving FTP in windows

Hi Bernhard,

in Windows I'm using Fling FTP (http://www.nchsoftware.com/ftp/index.html) to auto-save the files in FTP server while I save the file in Windows and it is working pretty well. It detects automatically changes in the files you want and send to the FTP Server!

Port to Windows

I tried using Fling as mentioned above but have serious problems uploading from a network drive. So I've decided to port this very useful bundle to e editor. I'll eventually add it as a project here: http://code.google.com/p/ebundles/ probably in a couple of weeks.

e texteditor supports FTP natively

no need for a FTP bundle, eTE supports this native. View the file menu

Filenames

Hello, and may i thank you for your good work in designing and keeping this bundle.

I find it works as expected. Recently I have jst found that it wont upload files whose names have seperated words. Eg. 'My Filename', but will handle 'MyFileneame'

The tooltip output is like this:

  • ftp: local: My/: no such file or directory
  • ftp: local: filename.txt: no such file or directory

So its breaking the name up. Is there any light on this? John P.

Strange

Spaces are handled by putting the whole local path between single ticks when using the FTP method. Please send me the error output of your FTP command by using the Contact form

Fantastic

This is a great bundle, many thanks - exactly what I've been after for quite a while now. One little thing - I tend not to use formal Textmate projects, preferring to use the ad hoc projects instead (I can't remember the precise terminology, but the projects created by just dragging a folder into Textmate). I noticed that this bundle doesn't work too well with that, and made a modification:

helper_functions.php, line 15 - this used to be:

$PROJECT_DIR = dirname($_ENV['TM_PROJECT_FILEPATH']);

I changed it to:

$PROJECT_DIR = $_ENV['TM_PROJECT_DIRECTORY'];

TM_PROJECT_DIRECTORY appears to yield the appropriate containing folder for the project, and now this works perfectly for me.

I would suggest first checking TM_PROJECT_DIRECTORY, then falling back to dirname(TM_PROJECT_FILEPATH), then falling back to dirname(TM_FILENAME), perhaps.

TM_PROJECT_DIRECTORY is not usable every time

TM_PROJECT_FILEPATH is not set because your "ad hoc" project is not saved already.

The problem with TM_PROJECT_DIRECTORY is: It contains the path to the top-level folder in the project drawer. If there is no folder because you only dropped files onto the project drawer TM_PROJECT_DIRECTORY contains the directory path of the first file in the drawer. If your first file was saved somewhere in a sub directory of your ad hoc project TM_PROJECT_DIRECTORY suddenly contains the sub dir path to the file but not the path you actually expected. At this point using TM_PROJECT_DIRECTORY fails.

That's why I only use TM_PROJECT_FILEPATH or the path to the current file (TM_DIRECTORY) as a fallback. Using TM_PROJECT_DIRECTORY as a fallback may work or not depending of the use of the project drawer.

Just save your project before using this bundle and you are fine. Let me know if you know something that may convince me to use TM_PROJECT_DIRECTORY :)

Good point, however

That's a very good point - I hadn't thought of that!

However, this plugin as-is (without the changes I made) wasn't too usable for me, as I would've had to set the ftp configuration for every subdirectory of my 'ad hoc' project - as far as I know, anyway.

Perhaps there's a way to support both - what about checking to see if TM_PROJECT_DIRECTORY is a prefix of TM_PROJECT_FILEPATH (i.e. the current file is within the project directory); if so, then all is well; otherwise, the situation you describe has occurred, and it's best to use dirname(TM_PROJECT_FILEPATH).

I will consider this in the

I will consider this in the next upgrade cycle.

You make my… year!

No comments: great, usefull, blablabla. Many thanks

Great

Awsome , i wish you 10 grandchildren for this bundle .

I'm working on...

meeting the preconditions :)

Exclude files

First of all I like to say that this bundle is great. I only have one thing and that is if there is a possibility to exclude files from upload e.g. setting in the .ftpssh_settings file certain files you would like to exclude from up/downloading

Cheers,

Jeroen

Interesting idea. I'll

Interesting idea. I'll consider this in the next (currently not planned though) upgrade to the bundle.

Snow leopard Textmate-PHP fix

Anybody else having problems with this bundle in Snow Leopard -- depending on your PHP setup, it might cause you issues. Here's my fix:

http://article.gmane.org/gmane.editors.textmate.general/29431

I'll fix that soon

Thanks to mention this here! The long term solution for the bundle will be to use the getenv() call instead of the $_ENV variable which is not loaded by default in PHP 5.3. I will release that fix soon.

ssh not working by default

At first I was puzzled by this error:

ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/lib/misc/ssh-askpass): No such file or directory
Permission denied (publickey,password,keyboard-interactive).

Then I realized you need to set up public key authentication. here's how to do it:
on REMOTE machine:
make sure you have ~/.ssh directory
if you don't, run:
ssh-keygen -t rsa
it will create one with correct permissions

on LOCAL machine:
run:
ssh-keygen -t rsa
if file .ssh/authorized_keys2 exists on remote machine then append to it, otherwise do this on LOCAL machine:
scp ~/.ssh/id_rsa.pub user@remote.server.com:.ssh/authorized_keys2

that's it!
now make sure that on your LOCAL machine file .ssh/id_rsa is secure!! if anyone copies it, they can get into your remote server without passwords

Use a password for the key

One note: In the ssh-keygen -t rsa step you get asked to enter a pass phrase for your SSH key. Don't miss that. You will be asked by MacOS to enter it once you want to use the key.

BTW: The need for public key authentication when using SSH is mentioned in the article above too.

remote file not found.tm_dialog

Hello Bernhard,

I'm getting an error as soon as I fill in the Remote Connection Settings window. It says "remote file not found.tm_dialog"

This is fresh install of textmate. Am I missing anything?

Thanks

Don't have a glue where this

Don't have a glue where this message comes from. Neither TextMate nor FTP/SSH Bundle does contain it.

May be you mean Remote settings file not found.? This is a standard note when opening the Settings window. It is probably somewhat useless at this point. Don't forget to create a TextMate Project before creating the Remote Settings for FTP/SSH. It will not work without a TextMate Project.

Same error here

I get the same error message:
Remote Settings file not found.tm_dialog: Property list invalid for format
{
host = "...."
password = xyz
...
}

PHP 5.3?

I usually edit my FTP/SSH settings directly in the settings file as described above in the article. Are you using PHP 5.3 (Max OS X 10.6 Snow Leopard)? May be that causes the problem.

I have Same error

I have Same error

Snow Leopard FIX

Hey everyone. I know Bernhard said he would release a fix that addresses the $_ENV problem, but I figured out a way to make the fix myself pretty quickly (about 5 minutes) and thought I'd share:

http://www.letsmakeitgo.com/blog/textmate-ftp-ssh-bundle-snow-leopard-fix/35/

tm_dialog "property list invalid for format"

It still doesn't work for me. I've made a fresh installation of TextMate 1.5.9 (1510) with FTP_SSH_v2.3.tmbundle.zip on my Snow Leopard 10.6.2 and I always get:

Remote settings file not found.tm_dialog: property list invalid for format { ... }

I've followed the two fix on Let's Make It Go (http://www.letsmakeitgo.com/blog/textmate-ftp-ssh-bundle-snow-leopard-fix/35/) replacing variables_order = “GPCS” with variables_order = “GPCSE” and doing a global find and replace of the regular expression \$_ENV\['([A-Z_]+)'\] with getenv('$1')

No way.

What else should I try?

Thank you

Snow Leopard fix + internal improvements

The previous fix had couple of problems,
we worked out a fix with Allan from Textmate, I issued a pull request to the original bugfix author but had no reply so far, so here is a fork:

https://github.com/alexouin/FTP-SSH.tmbundle

Regards,
Av'tW

This is working great for me

This is working great for me using php 5.3.3 on Mac OS 10.6.6
nice fork

change port setting

I can't seem to find a way to change the port from 22... Any help would be great. Really want to be able to use this plugin!

Cheers,

John

how to use a different port

I was able to get it to use a different port by passing in the following in .ftpssh_settings

cli_options = -P 1110

I was also having some issues

I was also having some issues transfer via generic ftp so i wrote a fork that utilizes curl:
https://github.com/jordanandree/FTP-SSH.tmbundle/

¡Gracias!

Thanks, mate. I thought it wouldn't work, because I could download but wasn't able to upload a modified file. It was my bad: one more slash than needed in the beginning.
En serio, gracias :)

Adding support for SSL or TLS

Is it possible to add SSL or TLS support for the FTP?