Я пытаюсь настроить Capistrano для развертывания моего проекта Node.js на одном из моих серверов.
Я создал ключ ssh, импортировал его в github, на мой сервер и мою машину (с ssh-add
)).ssh-add -l
перечисляет ключ, выполнение ssh git@github.com
успешно - отображает сообщение по умолчанию на github:
Привет, myusername!Вы успешно прошли аутентификацию, но GitHub не предоставляет доступ к оболочке.
Я использую Ruby 2.6.1 x64, Git 2.20.1 x64 и Windows 10 x64 (с OpenSSH, установленным через дополнительные функции системы).).
Мой config/deploy.rb
файл содержит следующее:
lock "~> 3.11.0"
set :application, "myproject"
set :repo_url, "git@github.myusername/myproject.git"
set :ssh_options, { forward_agent: true, keys: 'C:/Users/myusername/mydirectory/id_rsa.pub' }
set :branch, "master"
И config/deploy/production.rb
:
server "MYSERVERADDRESS", user: "MYSERVERUSER", roles: %w{apiServer}
set :ssh_options, { forward_agent: true, keys: 'C:/Users/myusername/mydirectory/id_rsa.pub' }
Запуск cap production deploy
выводит следующее:
00:00 git:wrapper
01 mkdir -p /tmp
Enter passphrase for C:/Users/myusername/mydirectory/id_rsa.pub:
MYSERVERUSER@MYSERVERADDRESS's password:
✔ 01 MYSERVERUSER@MYSERVERADDRESS 5.075s
Uploading /tmp/git-ssh-myproject-production-myusername.sh 100.0%
02 chmod 700 /tmp/git-ssh-myproject-production-myusername.sh
✔ 02 MYSERVERUSER@MYSERVERADDRESS 0.188s
00:05 git:check
01 git ls-remote git@github.com:myusername/myproject.git HEAD
01 Permission denied (publickey).
01 fatal: Could not read from remote repository.
01
01 Please make sure you have the correct access rights
01 and the repository exists.
#<Thread:0x00000000061737b0@C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `run'
11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/tasks/git.rake:18:in `block (3 levels) in eval_rakefile'
9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:97:in `with'
8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/tasks/git.rake:19:in `block (4 levels) in eval_rakefile'
7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/git.rb:38:in `check_repo_is_reachable'
6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/git.rb:77:in `git'
5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:78:in `execute'
4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `create_command_and_execute'
3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `tap'
2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `block in create_command_and_execute'
1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/netssh.rb:169:in `execute_command'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/command.rb:99:in `exit_status=': git exit status: 128 (SSHKit::Command::Failed)
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as MYSERVERUSER@MYSERVERADDRESS: git exit status: 128 (SSHKit::Runner::ExecuteError)
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
Похоже, что он не работает в момент выполнения git ls-remote git@github.com:myusername/myproject.git HEAD
.Странно то, что когда я запускаю git ls-remote git@github.com:myusername/myproject.git HEAD
вручную, это удается (независимо от того, делаю ли я это в cmd или в git bash, я пробовал их оба).
Я также пытался выполнить cap production deploy
в git bash, но это еще хуже, так как он не работает в тот момент, когда Capistrano ожидает от меня ввода ключевой фразы ключа RSA, выдавая Bad file descriptor (Errno::EBADF)
, прежде чем я смогу что-либо набрать, чего не происходит при запуске того же самого в cmd:
$ cap production deploy
00:00 git:wrapper
01 mkdir -p /tmp
Enter passphrase for C:/Users/myusername/mydirectory/id_rsa.pub:#<Thread:0x0000000006049d58@C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as MYSERVERUSER@MYSERVERADDRESS: Bad file descriptor (SSHKit::Runner::ExecuteError)
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/prompt.rb:45:in `noecho': Bad file descriptor (Errno::EBADF)
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/prompt.rb:45:in `ask'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:67:in `rescue in load_data_private_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:60:in `load_data_private_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:44:in `load_private_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:232:in `block in load_identities'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:225:in `map'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:225:in `load_identities'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:117:in `each_identity'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:85:in `block in authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:71:in `each'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:71:in `authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh.rb:246:in `start'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/connection_pool.rb:63:in `call'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/connection_pool.rb:63:in `with'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/netssh.rb:176:in `with_ssh'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/netssh.rb:129:in `execute_command'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `block in create_command_and_execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `tap'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `create_command_and_execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:78:in `execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/tasks/git.rake:8:in `block (3 levels) in eval_rakefile'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `run'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:116:in `read': Could not parse PKey: no start line (OpenSSL::PKey::PKeyError)
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:116:in `block in classify_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:61:in `load_data_private_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/key_factory.rb:44:in `load_private_key'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:232:in `block in load_identities'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:225:in `map'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:225:in `load_identities'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/key_manager.rb:117:in `each_identity'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:85:in `block in authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:71:in `each'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh/authentication/session.rb:71:in `authenticate'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/net-ssh-5.1.0/lib/net/ssh.rb:246:in `start'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/connection_pool.rb:63:in `call'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/connection_pool.rb:63:in `with'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/netssh.rb:176:in `with_ssh'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/netssh.rb:129:in `execute_command'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `block in create_command_and_execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `tap'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:145:in `create_command_and_execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:78:in `execute'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/capistrano-3.11.0/lib/capistrano/scm/tasks/git.rake:8:in `block (3 levels) in eval_rakefile'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/backends/abstract.rb:29:in `run'
from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sshkit-1.18.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as MYSERVERUSER@MYSERVERADDRESS: Bad file descriptor
Caused by:
Errno::EBADF: Bad file descriptor
Caused by:
OpenSSL::PKey::PKeyError: Could not parse PKey: no start line
Я что-то упустил в своей конфигурации или это проблема с Capistrano?Можно ли как-нибудь решить эту проблему?
Примечание. Я подставил данные, такие как имя пользователя, имя проекта github или пути к дискам, в прикрепленные файлы журналов и конфигурации