gogs: Cannot add SSH key when running via systemd
OS: CentOS 7. I have a systemd script setup to start gogs, when I am running via that systemd script I cannot add ssh keys and get the following error:
Sorry, we’re not able to verify your SSH key: ssh-keygen -lf: ssh-keygen: /tmp/keytest422813223: Permission denied
If I run the service by hand it works fine: sudo ./gogs web
Here is my systemd service:
[Unit]
Description=Gogs (Go Git Service)
After=syslog.target
After=network.target
#After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=redis.service
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/home/gogs/gogs
ExecStart=/home/gogs/gogs/gogs web
Restart=always
Environment=USER=root HOME=/home/gogs
[Install]
WantedBy=multi-user.target
Originally I had it setup to use the gogs user, but for testing I switched it to root. Still no luck.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 53 (35 by maintainers)
Commits related to this issue
- #2179 use Go sub-repo ssh to verify public key content — committed to gogs/gogs by unknwon 8 years ago
- #2179 use Go sub-repo ssh to verify public key content — committed to gogs/gogs by unknwon 8 years ago
- allow native and ssh-keygen public key check This commit adds the possibibility to use either the native golang libraries or ssh-keygen to check public keys. The check is adjusted depending on the se... — committed to Gibheer/gogs by Gibheer 8 years ago
Maybe, this is SELinux’s problem, you can try to execute the cmd below:
restorecon -R -v /git/.ssh
I have fix the problem by this way.
https://www.pyrosoft.co.uk/blog/2013/01/12/setting-up-ssh-authorized_keys-with-selinux-enabled/