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
buffer_get_ret trying to get more bytes 4 than in buffer 0 buffer error

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: