When I tried to add a SSH key to Gitlab 7.3.1 on Ubuntu 14.04 it didn’t work. I got an 500 internal server error and the site became extremly slow.

On refresh nothing is added and when I tried again, same problem over and over again.

Then I read the logs:

# tail -f /var/log/gitlab/gitlab-rails/production.log

Parameters: {“utf8″=>”✓”, “authenticity_token”=>”nKCheVvcyuhTrKUTrWbin9VOYpVPJEWk6lAJO63Lu9o=”, “key”=>……………………………….

…………………………………………….

………………………………………………………………….”}} Completed 500 Internal Server Error in 137ms

Errno::ENOMEM (Cannot allocate memory – ssh-keygen): lib/gitlab/popen.rb:23:in popen’ app/models/key.rb:78:inblock in generate_fingerpint’ app/models/key.rb:75:in generate_fingerpint’ app/controllers/profiles/keys_controller.rb:20:increate’

After thorougly searching, looking, praying, knuckleheading and swearing, I found the solution,

I needed to create a swap file.

#dd if=/dev/zero of=/swapfile bs=2048k count=1000
#mkswap /swapfile
#swapon /swapfile
#swapon -s
#chown root:root /swapfile
#chmod 0600 /swapfile
#echo 10 | sudo tee /proc/sys/vm/swappiness
#echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf

If for you this works, you can make it permanent by editing the following file: #nano /etc/fstab

add this line :

/swapfile       none    swap    sw      0       0

Hope this helps anyone out there in the Wasteland! :)