【问题标题】:Fatal: could not read Username for 'https://github.com': No such device or address致命:无法读取“https://github.com”的用户名:没有这样的设备或地址
【发布时间】:2013-09-24 01:38:46
【问题描述】:

几周以来,我一直在使用 github 和 capistrano 将我的 Rails 4 应用程序部署到 Rackspace。一切都很好,直到我最终将我的存储库设为私有。现在,我在运行“cap deploy”后收到以下错误:

“致命:无法读取'https://username@github.com'的密码:没有这样的设备或地址”

下面是我的 deploy.rb 文件中的代码

set :application, "appname"
set :repository,  "https://git_username@github.com/git_username/appname.git"
set :scm, :git
set :scm_username, "git_username"
set :scm_passphrase, "git_password"
set :scm_command, "git"
set :keep_releases, 5
set :branch, "master"
set :rails_env, "production"

set :deploy_to, "/var/www/doLocal"

set :user, "deployer"
set :password, "deployer_password"
set :use_sudo, false

ssh_options[:forward_agent] = true

server "/path/to/server", :app, :web, :db, :primary => true

after "deploy:restart", "deploy:cleanup"


namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

我已经尝试过在 github 存储库名称前添加和不添加用户名。如果它存在,我会收到上面的密码错误,但如果它不存在,我会收到以下错误:

“致命:无法读取 'https://github.com' 的用户名:没有这样的设备或地址”

知道问题是什么吗?我假设这与我更改为私有存储库有关。我已经阅读了一些关于使用 ssh 的内容,但也没有阅读。

任何建议或帮助将不胜感激!

【问题讨论】:

  • 能否尝试在 https url 中指定用户:https://user@github.com/username/repo.git
  • 我试过这样做,但得到了同样的错误,只是无法读取密码

标签: ruby-on-rails deployment github capistrano


【解决方案1】:

所以,我想通了。为了使用 Github 上的私有仓库使用 https 进行部署,您需要使用 Github 的 OAuth API。在您的 github 帐户上的 Edit Profile 下,单击 applications,然后生成 OAuth Token。然后,将您的令牌添加到您的 repo url,如下所示:

 set :repository,  "https://<OAuthToken>@github.com/username/application.git"

之后,我就可以跑了

 cap deploy

并将我的应用程序部署到我的远程服务器。

【讨论】:

  • 这是一种在服务器上的文件中包含 OAuthToken 的安全方法吗?谢谢!
【解决方案2】:

错误消息是一个通用的 git 错误,尽管问题本身是 Ruby 特定的。

因此,对于在这里登陆的其他任何人,这是一个非 Rails 答案:丢失的设备实际上是一个控制台。

  1. 您已尝试以非交互方式进行身份验证(即,使用 SSH 密钥)。这失败了。
  2. 作为后备方案,git 已尝试提示用户输入用户名,但这不起作用,因为交互式控制台不可用。

修复 #1,因为您可能不想在部署期间以交互方式进行身份验证。就我而言,这是一个 github oauth 问题。

【讨论】:

    【解决方案3】:

    fatal: could not read Username for 'https://github.com': No such device or address"

    首先检查github username 您的scm user 是否与您的代码中的服务器user 相同?

    你的代码

     set :scm_user, "user"
     set :user, "user"
    

    应该是

     set :user, "deployer"  # The server's user for deploys
     set :scm_user, "ram"  # The   github username
    

    同时设置密码

      set :scm_passphrase, "p@ssw0rd"  # The deploy user's password
    

    现在存储库案例..根据我认为您的存储库设置应该是

    set :repository, "git@github.com:username/repo.git"  # Your clone URL
    

    还有

     set :ssh_options, { :forward_agent => true }
    

    【讨论】:

    • 感谢您的回复!我尝试了所有这些,但没有奏效。正如您在上面澄清的那样,我没有正确设置用户名,但是更改存储库导致 capistrano 无法找到存储库并且它说“权限被拒绝(公钥)。致命:无法从远程存储库中读取。'
    猜你喜欢
    • 1970-01-01
    • 2019-06-24
    • 1970-01-01
    • 2013-03-22
    • 2017-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    相关资源
    最近更新 更多