title: Continuous deployment using Capistrano and Travis-CI
body: <p>I'm trying to deploy a Rails app to a VPS using Travis after following <a href="https://gist.github.com/lukewpatterson/4242707" rel="nofollow">this Gist</a>, and I'm hitting a few problems. I generate the encrypted ssh key on my server like so:</p>
  
  <pre><code>base64 --wrap=0 ~/.ssh/id_rsa &gt; ~/.ssh/id_rsa_base64
  ENCRYPTION_FILTER="echo \$(echo \"-\")\$(travis encrypt theodi/uk-postcodes \"\$FILE='\`cat $FILE\`'\" | grep secure:)"
  split --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_base64 id_rsa_
  </code></pre>
  
  <p>I then put the resulting encrypted vars into my <code>.travis.yml</code> file and put the reconstituted the private key <code>before_install</code> like so:</p>
  
  <pre><code>before_install:
    - echo -n $id_rsa_{00..30} &gt;&gt; ~/.ssh/id_rsa_base64
    - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 &gt; ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" &gt;&gt; ~/.ssh/config
  </code></pre>
  
  <p>I'm then running <code>cap production deploy</code> after a successful build like so:</p>
  
  <pre><code>after_success:
    - "[ \"$TRAVIS_BRANCH\" == \"master\" ] &amp;&amp; bundle exec cap production deploy"
  </code></pre>
  
  <p>But I'm still having no joy. The error I get on the Travis output (from Capistrano) is as follows:</p>
  
  <pre><code>INFO [5a729430] Running /usr/bin/env mkdir -p /tmp/uk-postcodes/ on 162.243.77.171
  DEBUG [5a729430] Command: ( RAILS_ENV=production /usr/bin/env mkdir -p /tmp/uk-postcodes/ )
  cap aborted!
  deploy
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/rvm1-capistrano3-1.1.1/lib/rvm1/tasks/capistrano3.rake:5:in `block (3 levels) in &lt;top (required)&gt;'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
  /home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
  </code></pre>
  
  <p>I've also tailed the <code>auth.log</code> on my server and I see the error <code>error: key_read: uudecode</code>. </p>
  
  <p>Any ideas where I might be going wrong? (There is a certain amount of cargo culting involved in the first step, but I think I understand what's going on)</p>