Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Capistrano rails应用程序部署失败。服务器可以';t将self标识为Github。权限被拒绝(公钥)_Ruby On Rails_Deployment_Capistrano_Deploying - Fatal编程技术网

Ruby on rails Capistrano rails应用程序部署失败。服务器可以';t将self标识为Github。权限被拒绝(公钥)

Ruby on rails Capistrano rails应用程序部署失败。服务器可以';t将self标识为Github。权限被拒绝(公钥),ruby-on-rails,deployment,capistrano,deploying,Ruby On Rails,Deployment,Capistrano,Deploying,我正在尝试使用Capistrano将rails应用程序部署到服务器 在本地,我运行了“cap production deploy”,然后出现了错误 12: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:31:in `run' 11: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/ss

我正在尝试使用Capistrano将rails应用程序部署到服务器

在本地,我运行了“cap production deploy”,然后出现了错误

    12: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:31:in `run'
    11: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
    10: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/capistrano-3.11.2/lib/capistrano/scm/tasks/git.rake:18:in `block (3 levels) in eval_rakefile'
     9: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:100:in `with'
     8: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/capistrano-3.11.2/lib/capistrano/scm/tasks/git.rake:19:in `block (4 levels) in eval_rakefile'
     7: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/capistrano-3.11.2/lib/capistrano/scm/git.rb:38:in `check_repo_is_reachable'
     6: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/capistrano-3.11.2/lib/capistrano/scm/git.rb:77:in `git'
     5: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:80:in `execute'
     4: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
     3: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:148:in `tap'
     2: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
     1: from /Users/rainbowtape/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/Users/-------------/.rvm/gems/ruby-2.6.5/gems/sshkit-1.20.0/lib/sshkit/command.rb:97:in `exit_status=': git exit status: 128 (SSHKit::Command::Failed)
git stdout: Nothing written
git stderr: git@github.com: Permission denied (publickey).
所以我去服务器端检查服务器是否可以和Github通信。它关掉了,但没有

deploy@xx.xx.xx.xx:~$ ssh -vT git@github.com
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Deprecated option "useroaming"
debug1: Connecting to github.com [140.82.118.4] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/deploy/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version babeld-2e9d163d
debug1: no match: babeld-2e9d163d
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/deploy/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/deploy/.ssh/id_rsa
debug1: Trying private key: /home/deploy/.ssh/id_dsa
debug1: Trying private key: /home/deploy/.ssh/id_ecdsa
debug1: Trying private key: /home/deploy/.ssh/id_ed25519
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
此外,我还尝试向ssh代理添加密钥。但失败了

deploy@xx.xx.xx.xx:~/.ssh$ eval "$(ssh-agent -s)"
Agent pid 4417
deploy@xx.xx.xx.xx:~/.ssh$ ssh-add ~/.ssh/authorized_keys
Error loading key "/home/deploy/.ssh/authorized_keys": invalid format
服务器端是否只有我的公钥。正确的?不是私钥。我走对了吗

更新1

使用
@ZedTuX
建议

我在服务器端生成了另一个ssh密钥集。并将公钥添加到github repo中,使其能够读/写。所以我在服务器端测试了git的pull和push。它起作用了。比特仍然得到这个错误。当我尝试在本地部署时

 DEBUG [1b7b3349]   error: could not lock config file config: Permission denied
 DEBUG [1b7b3349]   fatal: could not set 'remote.origin.url' to 'git@github.com:maskeduser1/repo1.git'
这对我来说毫无意义,因为我甚至可以
——将上游
设置为Github。为什么我会犯这个错误

我已经复制了我的本地公钥

这不是它的工作方式

首先,不要使用dev SSH密钥部署到服务器。此密钥具有读写权限,这很危险。 如果有人介绍您的服务器,他将拥有对Github存储库源代码的完全读/写访问权

而是使用部署密钥(在Github上,“设置>部署密钥”)。 因此,您可以使用
SSH-keygen
在服务器上生成一个新的SSH密钥,然后在Deploy-keys页面中从服务器复制/绕过公共SSH密钥

之后,您应该能够部署

更新 现在您有了这个错误:

DEBUG [1b7b3349]   error: could not lock config file config: Permission denied
DEBUG [1b7b3349]   fatal: could not set 'remote.origin.url' to 'git@github.com:maskeduser1/repo1.git'
您能否显示以下各项的输出:

  • whoami
  • ls-al~/.ssh
  • ls-al//repo

对于capistrano
repo
文件夹,请查看
:deploy_to
设置。如果您没有更改它,它应该在
/var/www/
文件夹中。

谢谢。我会试着那样做,然后回到你身边。它确实起了作用。所以我更进一步。但仍然会出现不同的错误。更新的帖子。“部署密钥”不提供读/写访问权限,它只提供读访问权限(这是服务器所需要的)。
DEBUG [1b7b3349]   error: could not lock config file config: Permission denied
DEBUG [1b7b3349]   fatal: could not set 'remote.origin.url' to 'git@github.com:maskeduser1/repo1.git'