-1

My deploy.rb file is

    lock '3.2.1'
    set :application, 'my_app'
    set :repo_url, 'path_to_git_repo.git'
    set :deploy_user, 'root'
    set :deploy_to, '/var/www'
    set :branch, 'master-final_code'
    set :scm, :git
    set :deploy_via, :copy
    set :format, :pretty
    set :stages, ["staging"]
    set :log_level, :debug
    set :pty, true

my staging.rb is

    set :stage, :staging
    role :app, %w{root@my_ip_add}
     %w{[root]}
    server 'my_ip_add', user: 'root', roles: %w{app}
    set :ssh_options, {
        forward_agent: false,
        auth_methods: %w(password),
        password: 'my_pass',
        user: 'root'
    }

Getting error:

Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

What should i do in this case? Should i edit config. of deploy.rb or staging.rb? Or is there any problem of ssh key?

1 Answers1

0

This is an ssh/git problem. There's two parts to the error message:

Permission denied (publickey,keyboard-interactive)

This means "I tried to connect to the git repo, but I couldn't." It doesn't say so explicitly, but it's in the format of an error from SSH. The part in brackets is telling you how it tried to authenticate: first using SSH keys, then via a keyboard prompt.

fatal: Could not read from remote repository

Because git couldn't connect to your git repo, it couldn't retrieve your code. Thus, your deployment fails.


One concerning thing about your code is that you're trying to deploy as root. This is a horrifically bad idea; not only are you storing your root credentials in your config files, but if you (or the Capistrano authors) have a bug in the deploy tasks or config, you could destroy the system. It's far better to create a deploy user with permissions for the deploy directory. That way, if something goes wrong - or someone gains access to the deploy account - they don't have complete access to the server. You should also be aware that many systems disallow root logins via SSH, often by default.

Alex P
  • 5,942
  • 2
  • 23
  • 30