Skip to content

Instantly share code, notes, and snippets.

@Packetslave
Created September 22, 2009 16:20
Show Gist options
  • Save Packetslave/191209 to your computer and use it in GitHub Desktop.
Save Packetslave/191209 to your computer and use it in GitHub Desktop.
Make capistrano use SCP instead of SFTP
# Deployment uses SFTP by default when you use deploy_via :copy, and there
# doesn't seem to be any way to configure it. Unfortunately, we don't run
# SFTP on our servers, so it fails. This forces it to use SCP instead.
# http://www.capify.org/index.php/OverridingTaskCommands
#
module UseScpForDeployment
def self.included(base)
base.send(:alias_method, :old_upload, :upload)
base.send(:alias_method, :upload, :new_upload)
end
def new_upload(from, to)
old_upload(from, to, :via => :scp)
end
end
Capistrano::Configuration.send(:include, UseScpForDeployment)
@doritostains
Copy link

Thank you!

@digitalronin
Copy link

Looks like the method signature of 'upload' has changed. I think this gist needs to change like this;

def new_upload(from, to, options = {}, &block)
old_upload(from, to, options.merge(:via => :scp), &block)
end

@johnbellone
Copy link

I actually had to use this today. Is this something that should be filtered down through the :copy_via parameter?

@dadarek
Copy link

dadarek commented Apr 4, 2013

This seems to work halfway for me. The file gets scp'd over (I see it on the remote server in the /tmp directory) but cap throws an error saying "SCP did not finish succesfully".

Anyone see this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment