Rails Capistrano deployment: SSH, Error reading response length from authentication socket

If you’re running a rails application with capistrano and you run into the following error:

Error reading response length from authentication socket

When you attempt to connect via cap, for instance

> cap staging deploy

Then make sure you can answer the following questions with a ‘yes’ before continuing.

1) Is my private key properly created and available on my local system. Simple configurations will generally maintain the key at:

~/.ssh/id_rsa

2) Is my public key available on the remote server. If not, you will need to add it to the authorized_keys file on the remote server:

~/.ssh/authorized_keys

Your public key can be found in the following location (on your local machine):

~/.ssh/id_rsa.pub (or whatever your public key pairing is for your situation)

and paste it as a newline in the above file on the remote server (authorized_keys).

If you are still experiencing the authentication socket error, do the following at your local command prompt:

> eval $(ssh-agent)
> ssh-add

This is particularly important if you are using a private:public key pairing and expecting capistrano to allow agent forwarding.

5 thoughts on “Rails Capistrano deployment: SSH, Error reading response length from authentication socket

  1. Vijaysinhparmar

    I tried your steps but still I am getting error… could you please help?

    Jay Bhavani@VijaysinhParmar MINGW64 /e/wamp64/www/demo (master)
    $ cap production git:check
    00:00 git:wrapper
    01 mkdir -p /tmp
    ✔ 01 [email protected] 2.377s
    ✔ 01 [email protected] 2.395s
    Uploading /tmp/git-ssh-demo-production-Jay Bhavani.sh 100.0%
    Uploading /tmp/git-ssh-demo-production-Jay Bhavani.sh 100.0%
    02 chmod 700 /tmp/git-ssh-demo-production-Jay\\\\ Bhavani.sh
    ✔ 02 [email protected] 0.045s
    ✔ 02 [email protected] 2 0.046s
    00:02 git:check
    01 git ls-remote [email protected]:vijaysinhparmar/demo.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.
    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.
    (Backtrace restricted to imported tasks)
    cap aborted!
    SSHKit::Runner::ExecuteError: Exception while executing as [email protected] 2: git exit status: 128
    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.

    SSHKit::Command::Failed: git exit status: 128
    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.

    Tasks: TOP => git:check
    (See full trace by running task with –trace)

    Reply
    1. Anthony Leon Post author

      Vijaysinhparmar – it looks like you need to add your public key to your bitbucket account. The error you’re receiving isn’t related to your local client to your remote server, but to your remote server to bitbucket.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *