【发布时间】:2014-01-21 21:49:03
【问题描述】:
在关注this Gist 之后,我正在尝试使用 Travis 将 Rails 应用程序部署到 VPS,但遇到了一些问题。我在我的服务器上生成加密的 ssh 密钥,如下所示:
base64 --wrap=0 ~/.ssh/id_rsa > ~/.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_
然后,我将生成的加密变量放入我的 .travis.yml 文件中,并将重构后的私钥 before_install 放入,如下所示:
before_install:
- echo -n $id_rsa_{00..30} >> ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
在像这样成功构建之后,我正在运行cap production deploy:
after_success:
- "[ \"$TRAVIS_BRANCH\" == \"master\" ] && bundle exec cap production deploy"
但我仍然没有快乐。我在 Travis 输出(来自 Capistrano)上得到的错误如下:
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 <top (required)>'
/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'
我还在我的服务器上跟踪了auth.log,我看到了错误error: key_read: uudecode。
我可能会出错的任何想法? (第一步涉及到一定数量的货物培养,但我想我明白是怎么回事了)
【问题讨论】:
-
你生成的key,是给你的机器还是给travis机器的?
-
它们是给我的服务器的。 Travis 会为每次测试运行生成小框,因此无法进行正常的公钥/私钥身份验证。
标签: ruby-on-rails ruby capistrano travis-ci