Capistrano asks for password when deploying, despite SSH keys

前端 未结 7 1774
-上瘾入骨i
-上瘾入骨i 2020-12-22 23:14

My ssh keys are definitely set up correctly, as I\'m never prompted for the password when using ssh. But capistrano still asks for a password when deploying with cap d

7条回答
  •  忘掉有多难
    2020-12-22 23:38

    The password prompt is because the server you are deploying to is connecting to the git server and needs authentication. Since your local machine (where you are deploying from) already has a valid ssh-key, use that one by enabling forwarding in your Capfile:

    set :ssh_options, {:forward_agent => true}
    

    That forwards the authentication from your local machine through when the deployment server tries to connect to your git server.

    This is much preferred to putting your private key out on the deployment server!

    Another way of getting around the password prompt when the server is ssh'ing back on itself is to tell capistrano not to do so. Thanks to the 'readme' section for Daniel Quimper's capistrano-site5 github repo, we note the following:

    set :deploy_via, :copy
    

    Obviously, this works for the case where both the app and git repository are being hosted on the same host. But I guess some of us are doing that :)

提交回复
热议问题