How to fix buffer_get_ret: trying to get more bytes 4 than in buffer

I got this error after adding new user to the system (CentOS). The user key is generated using PuTTY Key Generator (PuTTYgen for short).

Exact error (in /var/log/secure):

...
Apr  3 08:57:13 hostname sshd[28041]: error: buffer_get_ret: trying to get more bytes 4 than in buffer 0
Apr  3 08:57:13 hostname sshd[28041]: fatal: buffer_get_int: buffer error
Apr  3 08:58:23 hostname sshd[29722]: error: buffer_get_ret: trying to get more bytes 4 than in buffer 0
Apr  3 08:58:23 hostname sshd[29722]: fatal: buffer_get_int: buffer error
Apr  3 08:59:20 hostname sshd[30331]: error: buffer_get_ret: trying to get more bytes 4 than in buffer 0
Apr  3 08:59:20 hostname sshd[30331]: fatal: buffer_get_int: buffer error
...

Check your SSH key for extra line.

It should be someting like this:

ssh-rsa xipHymgupZdTaSvXsO2uAJ8fGvyx6kTkO/lIqF6fOayYnllq9Vf4DX9XRaUH8tCN34Vu7jJi5ZjuHe35xipHymgupZdTaSvXsO2uAJ8fGvyx6kTkOID735f2myg90XQDJRwRL5PtU0HJKM7dlJ33$
rsa-key-20100403

Not like this:

ssh-rsa
xipHymgupZdTaSvXsO2uAJ8fGvyx6kTkO/lIqF6fOayYnllq9Vf4DX9XRaUH8tCN34Vu7jJi5ZjuHe35xipHymgupZdTaSvXsO2uAJ8fGvyx6kTkOID735f2myg90XQDJRwRL5PtU0HJKM7dlJ33$
rsa-key-20100403

Notice the hard return after ssh-rsa.

The key was copy-pasted from PuTTYgen to nano. Apparently, PuTTYgen add extra hard return after ssh-rsa, see screenshot:

buffer_get_ret trying to get more bytes 4 than in buffer 0 buffer error

Comments

OMFG. That was easy. Between permissions and that return from my client-side pub key... I always have a hell of a time getting keys to run smoothly.

Here are the permissions I have used for my .ssh dir:

drwx------ 8 owner group 272 Sep 29 13:17 .
drwxr-xr-x 38 owner group 1292 Oct 2 04:47 ..
-rwx------ 1 owner group 2472 Dec 14 2009 authorized_keys
-rwx------ 1 owner group 1227 Mar 30 2010 config
-rw------- 1 owner group 1675 Dec 12 2009 id_rsa
-rw-r--r-- 1 owner group 417 Dec 12 2009 id_rsa.pub
-rwx------ 1 owner group 18317 Oct 2 04:23 known_hosts
-rw-r--r-- 1 owner group 45 Mar 16 2010 ssh_config

thanks. that really bugged me for some time. it really helped alot your how to ;)

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

If you enjoyed this post, make sure you subscribe to our RSS Feed! Or if you prefer, you can Follow us on Twitter instead.