Search code examples
ruby-on-railsgitsshcapistranobitbucket

Capistrano and Bitbucket Deployment


Using Capistrano version 3.4.0

  1. I have created a ssh key on my centos 7 server
  2. I have set that ssh key on bitbucket
  3. repo url set as follows on my deploy.rb file :

    set :repo_url, '[email protected]:Username/myProjectName.git'

  4. on my production.rb file:

    role :myProjectName, %w{[email protected]}

    set :ssh_options, { auth_methods: %w(password), password: "mybitbucketpasswordhere" }

  5. i checked if i can login with my username with ssh -T [email protected] command:

    logged in as Username.

  6. cap production deploy in my project folder and i get following error :

    INFO [90fbd4ee] Running /usr/bin/env mkdir -p /tmp/myProjectName/ as [email protected] DEBUG [90fbd4ee] Command: /usr/bin/env mkdir -p /tmp/myProjectName/ (Backtrace restricted to imported tasks) cap aborted! Net::SSH::AuthenticationFailed: Authentication failed for user [email protected]

    Tasks: TOP => git:check => git:wrapper (See full trace by running task with --trace) The deploy has failed with an error: Authentication failed for user [email protected]

Where do i go wrong ?

Thanks in advance.


Solution

  • You've added your SSH Key, which should mean you don't need to provide a password. So this line: set :ssh_options, { auth_methods: %w(password), password: "mybitbucketpasswordhere" } is incorrect.

    I believe the default for capistrano is to use SSH authentication, so try just removing that line.