I'm trying to use Sublime Text 2 as an editor when I SSH in to my work server, and I'm stumped. I found this http://urbangiraffe.com/2011/08/13/remote-editing-with-sublime-text-2/ (among many other posts) that looks like it might help, but I don't follow it exactly, particularly with what values I should put in for the remote variable in line 5. I set "/Users/path/to/local/copy" to my local root directory, but I don't know if that's right or if there's more to do. Any thoughts? I'm on OSX10.8


当前回答

一个对我来说非常有用的解决方案——在Mac上进行本地编辑,然后让文件自动同步到远程机器上

Make sure you have passwordless login to the remote machine. If not, follow these steps http://osxdaily.com/2012/05/25/how-to-set-up-a-password-less-ssh-login/ create a file in ~/Library/LaunchAgents/filesynchronizer.plist, with the following content: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>filesynchronizer</string> <key>ProgramArguments</key> <array> <string>/usr/bin/rsync</string> <string>-avz</string> <string>/Users/USERNAME/SyncDirectory</string> <string>USERNAME@REMOTEMACHINE:~</string> </array> <key>WatchPaths</key> <array> <string>/Users/USERNAME/SyncDirectory</string> </array> </dict> </plist> In a terminal window run launchctl load ~/Library/LaunchAgents/filesynchronizer.plist That's it. Any changes to any files in ~/SyncDirectory will be synchronized to ~/SyncDirectory on the remote machine. Local changes will override any remote changes.

这将创建一个监视SyncDirectory的launchd作业,当有任何更改时,将运行rsync将该目录同步到远程计算机。

其他回答

有三种方法:

Use SFTP plugin (commercial) http://wbond.net/sublime_packages/sftp - I personally recommend this, as after settings public SSH keys with passphrase it is safe, easy and worth every penny http://opensourcehacker.com/2012/10/24/ssh-key-and-passwordless-login-basics-for-developers/ Mount the remote as local file system using osxfuse and sshfs as mentioned in the comments. This might be little difficult, depending on OSX version and your skills with UNIX file systems. Hack together something like rmate which does file editing over remote tunneling using some kind of a local daemon (very difficult, cumbersome, but sudo compatible) http://blog.macromates.com/2011/mate-and-rmate/

此外,理论上,你可以在远程服务器上安装X11,并通过VNC或X11转发在那里运行Sublime,但这将非常缓慢。

Lsyncd似乎是SSHFS方法的一个不错的替代方案。如果你使用“-delay 0”,它可以实时工作。

I am on MacOS, and the most convenient way for me is to using CyberDuck, which is free (also available for Windows). You can connect to your remote SSH file system and edit your file using your local editor. What CyberDuck does is download the file to a temporary place on your local OS and open it with your editor. Once you save the file, CyberDuck automatically upload it to your remote system. It seems transparent as if you are editing your remote file using your local editor. The developers of Cyberduck also make MountainDuck for mounting remote files systems.

使用FileZilla

这适用于Mac和Windows用户(我在Mac上使用)。多年来,我使用了列出的几个答案,发现FileZilla很适合我在有SSH访问权限的远程主机上编辑文件时的需求。它的设置也很快。

我配置一个新的服务器连接 连接到服务器 右键点击我想编辑的文件,选择查看/编辑。

这会打开我的默认编辑器(Sublime),但它可以与任何编辑器一起工作 已安装的编辑器。

一旦我保存了文件,Filezilla会自动提示我是否要“将该文件上传到服务器”,我点击“是”,然后它就更新了。

另一个类似于osxfuse的mac解决方案是只使用Panic Software的传输FTP客户端,它允许您将远程文件夹挂载为本地磁盘。它支持SFTP,非常安全。