Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to deploy a PHP application onto a Linode server with Capistrano. I've installed Ruby and Capistrano, and configured my deploy.rb file (possibly incorrectly).

However, when I run cap deploy I receive this error:

[deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: (Net::SSH::AuthenticationFailed: myusername) connection failed for: (Net::SSH::AuthenticationFailed: myusername)

Here's my deploy.rb file:

set :application, "App name"
set :repository,  ""
set :user, "root"
set :password, "sshpassword"
set :scm, :git
set :deploy_to, "/srv/www/"

set :deploy_via, :remote_cache
set :use_sudo, false
set :copy_exclude, [".git", ".DS_Store", ".gitignore", ".gitmodules", "Capfile", "config/deploy.rb"]

set :ssh_options, {:forward_agent => true}

server "", :app

I've verified the username and password work for SSH (I've logged into SSH from the terminal with those credentials).

Any ideas? Any help would be greatly appreciated! I can clarify the question if needed :)

share|improve this question
up vote 0 down vote accepted

The issue may be that you have set :user as "root" but then you SSH into the server as "myusername". You are correct in setting use_sudo to false but there should be a user dedicated to deployments. Create a user to deploy the app and make sure the /srv/www/ is owned by that user. You would want your user setup to be something like:

set :user, "deployer"
set :group, "deployer"
set :password, "sshpassword"

server "", :app
share|improve this answer
Thanks, I'll give it a try and let you know how it goes – Andrew Sep 10 '13 at 19:28
Does the linode username have to match the SSH username? – Andrew Sep 10 '13 at 20:54
No you can have a totally different SSH user or multiple SSH users. I would recommend not SSHing as root. – Manny T Sep 11 '13 at 15:01
Thank you! Why not SSH as root? Is there a security risk associated with it? – Andrew Sep 11 '13 at 18:44
Since the root user has access to do absolutely anything on a system, if someone with malicious intent got access, they could cause a lot of damage. Having a password for ssh access opens you up to brute force password cracking attempts. Generally you would log in as another user and use the command sudo su - to switch to root. You could also run a one time command by using sudo (ie sudo <command>). You can do away with passwords by setting up ssh-keys. For a personal server you might get by with a really strong password for root. – Manny T Sep 12 '13 at 2:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.