SSHD Error: buffer_get_ret: trying to get more bytes 4 than in buffer 0

If you have run in to an error similar to this in your /var/log/secure log file:

Oct  2 21:12:05 phptest sshd[31998]: error: buffer_get_ret: trying to get more bytes 4 than in buffer 0
Oct  2 21:12:05 phptest sshd[31998]: fatal: buffer_get_int: buffer error

Check your public key in ~/.ssh/authorized_keys or ~/.ssh/authorized_keys2 in a text editor and make sure each key is on one line. The prefix “ssh-rsa” followed by a space and then your key should all be on one line, and you might also have a comment after that describing the key. If your key spans multiple lines you will often get an error similar to the above message in your /var/log/secure log file.

You usually only see this when you’re trying to connect using key-based authentication. The error is caused by extra newlines in the authorized_keys list. When copying a public key out of PuttyGen(or similar key-generation software), because the key spans multiple lines, you can end up with extra newlines in the text when it gets copied to the clipboard.

1 Comment


  1. Hey there, thanks for your help.
    This issue could happen when there are extra lines in the known_hosts file as well. See ya!