1

I tried gaining write permissions to change an HTML file on a remote server that runs Fedora using:

sudo chown -R $USER:$USER /var/www

After entering this line in the terminal connected to the terminal on the server with SSH I am no longer able to connect to the server with FileZilla or establish a new SSH connection with a terminal.

Filezilla: Status: Using username "opc". Status: Server refused our key Error: Could not connect to server

SSH: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

I have tried:

sudo chmod 755 /var/www/html

sudo chown -R root:root /var/www

Any help would be greatly appreciated!

2
  • Instead of /var/www you didn't by mistake write that as /var /www or some other combination that contains a space? Mar 5, 2023 at 0:07
  • I appears that somehow, the entie .ssh folder vanished. I now created a new key pair. Created a authorized_keys file withing the .ssh folder. Copied the public key into the authorized keys file. Created a new .key file on my local machine and copied the private key into it. Trying to connect with SSH using the new key still gives me "Permission denied (publickey,gssapi-keyex,gssapi-with-mic)" Mar 5, 2023 at 0:18

1 Answer 1

2

These two things, your messing with /var/www-permissions and your ssh access should be completely unrelated, unless your user opc has a home dir under /var/www. If that is the case, go to the home dir of opc and

chown -r opc .ssh
chmod 600 .ssh/*
chmod 700 .ssh

Ssh will not connect if the .ssh directory and its contents is owned by a different user or if .ssh's permissions are wrong.

Next step is to read about permissions for your webserver. Just bluntly changing ownership and/or permissions is a source of trouble and may even become a security exposure.

5
  • I am not sure how it happened, but the ./home/opc/.ssh seems to be missing: Mar 4, 2023 at 23:14
  • chown -R opc .ssh chown: cannot access '.ssh': No such file or directory Mar 4, 2023 at 23:14
  • @jjjjjjjjjjjjjjjjjjjjjjj your ./home/opc/.ssh path starts with a dot, which means "current directory". So unless you are in / it's to be expected that ./home/opc/.ssh won't exist Mar 5, 2023 at 0:09
  • Thank you so much! After recreating all the ssh files after they had vanished it still did not work. Using these 3 lines on the new .ssh folder now fixes the problem. Mar 5, 2023 at 0:21
  • @jjjjjjjjjjjjjjjjjjjjjjj please remember to accept the answer that works best for you. You do this with the tick mark next to the appropriate answer Mar 5, 2023 at 5:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .