Monday, March 25, 2013

SSH passwordless login - debug2: we did not send a packet, disable method

When managing a lot of server it's quite convenient to set up SSH to login without asking for a password. The method consists of just 4 simepl steps.




  1. generate a public and a private key pair
    ssh-keygen -f keysfile
  2. upload the public key to the server in your home folders "~/.ssh" directory (create it if it's not there)
    keysfile.pub to remotehost/~/.ssh folder
  3. dump that key to the accepted keys (in the same .ssh folder)
    cat keysfile.pub > authorized_keys
  4. login to the server using the private key from your client
    ssh -i keysfile username@remotehost
If something goes wrong, try running SSH with debug messages:
ssh -i keysfile username@remotehost -vv

If you see the following error message:
debug2: we did not send a packet, disable method
it's most probably because the server cannot access the authorized_keys file. Some howtos just add your keyfile's name to authorized_keys but that failed for me all the time. Dumping the public key to the file solved this problem.

6 comments:

  1. thanks! this help me to solve my problem...

    $ sudo chmod 700 ~/.ssh
    $ sudo chmod 600 ~/.ssh/*

    ReplyDelete
  2. setting permissions helped me:

    sudo chown -R `whoami` ~

    ReplyDelete
  3. check your sever log file.
    one problem occurred to me is my home directory has write permission for the group.
    Removing that will solve the problem.

    ReplyDelete
    Replies
    1. Thankfully this kind of information gets stored online and findable by search engines ;-)

      Thanks for sharing (obviously your tips really helped me)!

      Delete
  4. This comment has been removed by the author.

    ReplyDelete