Permissions - SSH Keys, Git and Files

Problem Description

I am trying to setup a learning Larvel project. I have tried to setup git for pulling the needed files. When logged in as the Sympl user running: ssh-keygen -t rsa -b 4096 -C “SOMETHING” to create my key for github I get the following error:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/sympl/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key “/home/sympl/.ssh/id_rsa” failed: Permission denied

Why would I not have permission to create the key for this user. Do I need to always login as root to do this? This leads me onto trying to get this to work with the Sympl user and doing sudo on it and forcing it to generate the key in the sympl user folder. Then I try and do the pull I get the are you sure you know what server this is but it too error because of permissions.

The authenticity of host ‘github.com (20.26.156.215)’ can’t be established.
REMVOED key fingerprint is SHA256:+/.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/home/sympl/.ssh/known_hosts).
Load key “/home/sympl/.ssh/id_rsa”: Permission denied
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Again sudo works as expected. How the heck can I run git pull without sudo or root?!

This leads me onto another issue with folder permissions. Laravel needs everything under /storage to be read and writable. Checking the folders and files they are all set to 775 which I understand should work but just throws errors about not being able to write to the folder and files. Changing the permissions logged in via SFTP throws errors about being unable to change the permissions for anything, again root works but toggling or fiddling with these permissions doesn’t change anything.

This all seems related and points to some errors in my install (?) or its working as expected and I am being stupid.

Any Error Messages

See Above in context.

Environment

  • Sympl Version: 12
  • Sympl Testing Version: -
  • Debian Version: 12
  • Hardware Type:
  • Hosted With:

It sounds like something isn’t right with your permissions on /home/sympl/.ssh.

If you run this, it should fit it up:

sudo chown sympl:sympl /home/sympl/.ssh
sudo chmod 700 /home/sympl/.ssh

You should then be fine to get git and so on working normally.

For the storage directory, just make sure it’s in the public directory for the site, and you can set permissions when logged in as the normal sympl or root users.

Thanks! That solved it. I did have to also do the same to the the id_rsa.pub file before it would let me create the ssh key!

As for the storage folder that’s under the public folder but not under htdocs. So it should work?

Yes, that should work fine - by default, PHP has access to the public/ directory and everything in it, rather than just the contents of htdocs/.