"New key" should fix misformatted SSH key to prevent "error: key_read: uudecode" while cloning repo
Created by: mikem2005
Steps to reproduce (Ubuntu 12.04)
- Create a SSH key with ssh-keygen
- 'cat' public key to terminal
- Copy key from terminal and paste into the GitLab "key" textfield.
- Click 'Save', observing that everything appears to have worked correctly
- Attempt to git clone a repo
- Observe prompt for git@... password. This means that ssh is falling back to password auth because the public key on the server was invalid. Digging into server's /var/log/auth.log I noticed a line "error: key_read: uudecode AAAA...that has a space and ends with \n". Thus, it appears that copying a copy with line breaks into the textfield causes a multi-line entry in authorized_keys, which is not allowed.
Fix:
- Remove linebreaks from key before persisting
auth.log Lines: Jun 4 18:10:00 git sshd[7731]: error: key_read: uudecode AAAAB3NzaC1yc2EAAAADAQABAAABAQC5akdhG/P1tioNGsXKCyOcJH+BxKGNu2Q1L1UhPlIRtDZfCYARDbAgYy8uobrOe9kaCDnPK5UR+jJUlNs0Zy3NaGio+1awc t Ljt/X5AavWOIqW9qJYxo7ZJL8SV5Qz8ihEu9WQKJGkQoelEnEhS9HUBgZ39zAglZ+yMHrscb4Fh58774w1QgWws7BkHlsCQHMy7ynQyWSPBuasuvq6u6v7G+gSTOMK0dLGL6ae\n failed Jun 4 18:10:06 git sshd[7731]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.10.101 user=git Jun 4 18:10:08 git sshd[7731]: Failed password for git from 192.168.10.101 port 59080 ssh2