0

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: myusername@lish-atlanta.linode.com (Net::SSH::AuthenticationFailed: myusername) connection failed for: myusername@lish-atlanta.linode.com (Net::SSH::AuthenticationFailed: myusername)

Here's my deploy.rb file:

set :application, "App name"
set :repository,  "https://github.com/MyProject/Main.git"
set :user, "root"
set :password, "sshpassword"
set :scm, :git
set :deploy_to, "/srv/www/myproject.com/htdocs"

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 "myusername@lish-atlanta.linode.com", :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 :)

Andrew
  • 195
  • 1
  • 1
  • 8

1 Answers1

0

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/myproject.com/htdocs 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 "deployer@lish-atlanta.linode.com", :app
Manny T
  • 68
  • 1
  • 6
  • 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 `). You can do away with passwords by [setting up ssh-keys](https://library.linode.com/security/ssh-keys). For a personal server you might get by with a really strong password for root. – Manny T Sep 12 '13 at 02:59