Roots Discourse

I'm having trouble getting Capistrano to work with Bedrock


#1

Hello,

I cannot seem to get Capistrano to work with bedrock. I’m getting some sort of error on the deploy:check.
SSHKit::runner::ExecuteError: Exception while executing on host … Connection refused - connect(2) for … port 22.

I think the problem is with the configuration of the staging.rb file inside of the deploy/ folder, but for the sake of it i will explain what i’ve done so far.

So far I have:
Setup bedrock as usual.

Made sure I have ssh access to the server, and also made sure that the repository of the project is not a private repository.

I’ve cloned the Capistrano repo into my bedrock project, after which i moved the capfile, gemfile and gemfile.lock into the root of the project and moved the deploy/ folder and deploy.rb file into the config directory.
After finishing these steps i ran bundle install.

On the server i have setup a test domain: capistrano.somedomain.com, to which i’ve added a .env file with the right configuration for the project, nothing else just the .env file.

I’ve made the following modifications to the deploy.rb file:

  • Set the application name to: Capistrano
  • Set the git url of the repo, this is without https://, i’m using bitbucket btw
  • Set the deploy to path to: /home/user/capistrano.somedomain.com

To the staging.rb file i’ve set the server line to:
ssh -p 4000 user@host

This is the line i use to ssh to the server, i’m not sure this is correct.
A good thing to note would be that i ran the ssh agent to get access to the server.

Thank you for taking the time to help me, any tips would be very welcome!


#2

Can you share the contents of your staging.rb file? It’s hard to help without seeing exactly what you’re trying :slight_smile:

Looking at https://github.com/roots/bedrock-capistrano/blob/master/config/deploy/staging.rb and based on the documentation it links to, it seems like you’d want to uncomment the ssh_options part and set your port there.

You should be defining the username right after server, the default user is deploy.

For the port, try:

set :ssh_options, {
  keys: %w(~/.ssh/id_rsa),
  forward_agent: false,
  port: '2222'
}

#3

Thanks for replying!

Here’s my staging.rb configuration:


role :app, %w{capistrano.sjoerdvermeijden.nl}
#role :web, %w{deploy@example.com}
#role :db, %w{deploy@example.com}

server ‘capistrano.sjoerdvermeijden.nl’, user: ‘deploy’, roles: %w{web app db}

set :ssh_options, {
keys: %w(~/.ssh/id_rsa),
forward_agent: false,
auth_methods: %w(MyPassword),
port: ‘4000’
}

fetch(:default_env).merge!(wp_env: :staging)


I have set the username to deploy, but as i’m reading the documentation i’m realising i haven’t set up a user, this is probably the reason for: Authentication failed for user deploy@capistrano.sjoerdvermeijden.nl.

According to the documentation i need to run: adduser deploy, this gives me an error of command not found on the server as wel as locally. Do i need to have something installed for this to work?
http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/

I am also using port 4000 instead of 2222 because the line I use to ssh to the server is ssh -p 4000 user@host.

Finally when running the deploy:check command i’m getting this error: Object#timeout is deprecated, use Timeout.timeout instead. cap aborted!
Looks like this is something that needs to be fixed aswel, i’ve tried updating the ruby version to 2.4.0 but that just gives me a different error.
Exception while executing on host capistrano.sjoerdvermeijden.nl: undefined method `e=’ for #OpenSSL::PKey::RSA:0x007ff491922ec0

Again thanks for replying, i hope you can help me out.
Thanks!


#4

Oke so i just found out you can’t add a deployment user on shared hosting so i will have to fix that first!


#5

I’m pretty sure you can’t connect to the Bitbucket on a different port than 22. https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html .