Fatal: could not read Username for 'https://github.com': No such device or address
Asked Answered
M

3

10

I have been deploying my Rails 4 application to Rackspace using github and capistrano for a few weeks now. Everything worked fine until I finally made my repository private. Now, I am receiving the following error after running 'cap deploy':

"fatal: could not read Password for 'https://[email protected]': No such device or address"

Below is the code from my deploy.rb file

set :application, "appname"
set :repository,  "https://[email protected]/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

I have tried it with and without the username prepended to the github repository name. If it is there, I receive the password error from above, but if it is not there, I receive the following error:

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

Any idea what the issue is? I'm assuming it has something to do with me changing to a private repository. I have read some things about using ssh but have also read not to.

Any suggestions or help would be much appreciated!

Monkhmer answered 19/9, 2013 at 5:22 Comment(2)
Could you try and specify the user in the https url: https://[email protected]/username/repo.gitParasiticide
I tried doing that but then got the same error except that the Password could not be readMonkhmer
M
19

So, I figured it out. In order to use a private repo on Github to deploy using https, you need to use Github's OAuth API. Under Edit Profile on your github account, click applications and then generate an OAuth Token. Then, prepend your token to your repo url like so:

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

After that, I was able to run

 cap deploy

and deploy my application to my remote server.

Monkhmer answered 25/9, 2013 at 18:27 Comment(1)
Is this a secure method of doing this having the OAuthToken in a file on the server? Thanks!Knecht
C
18

The error message is a generic git error, though the question itself is Ruby specific.

So for anyone else that landed here, here's a non-rails answer: the missing device is actually a console.

  1. You've tried to authenticate non-interactively (ie, using an SSH key). This has failed.
  2. As a fallback, git has tried to prompt the user to input a username, but this doesn't work as an interactive console is not available.

Fix #1, since you probably don't want to authenticate interactively during a deploy. In my case it was a github oauth issue.

Chattel answered 10/2, 2014 at 11:45 Comment(0)
S
0

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

check the github username first Also your scm user is same as server user in your code?

Your code

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

It should be

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

also set the passphrase

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

Now repository case..As per I think you repository setting should be

set :repository, "[email protected]:username/repo.git"  # Your clone URL

Also

 set :ssh_options, { :forward_agent => true }
Seel answered 19/9, 2013 at 5:43 Comment(1)
Thank you for your response! I tried all of those, but it did not work. I did not have the username set up correctly as you clarified above, but changing the repository resulted in capistrano not being able to find the repository and it said 'Permission denied (publickey). fatal: Could not read from remote repository.'Monkhmer

© 2022 - 2024 — McMap. All rights reserved.