Setting Up Emacs + Cygwin + PHP + ssh-agent

I had to struggle for a while to be able to remotely edit php files with emacs on Windows.  After trying various combinations of putty/plink, cygwin, xemacs, and GNU emacs, I finally got things to work with Cygwin’s ssh-agent and GNU emacs.  Here’s the procedure:

Install Cygwin, ssh-agent, emacs.  Use ssh-keygen to create a private/public pair.  Append the public key to your ~.ssh/authorized_keys file on the remote machine.  Add this to your ~/.bash_profile in Cygwin:

SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS=”-s”
if [ -z “$SSH_AUTH_SOCK” -a -x “$SSHAGENT” ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap “kill $SSH_AGENT_PID” 0
fi

ssh-add ~/.ssh/id_rsa

Add this to your emacs load path (.emacs, init.el, whatever):

(require ‘tramp)
(setq tramp-default-method “sshx”)
(setq tramp-debug-buffer t)
(add-to-list ‘load-path “~/.xemacs”)
(autoload ‘php-mode “php-mode” “Major mode for editing php code.” t)
(require ‘php-mode)

And the link for php-mode is here:

wget http://php-mode.svn.sourceforge.net/svnroot/php-mode/tags/php-mode-1.5.0/php-mode.el


Posted

in

by

Tags:

Comments

Leave a Reply