Issue
i try to connect to my Linux centOS server with Root user on port 22 with this command:
ssh -p 22 root@ip
but connection return this error:
root@ip: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
what should i do?
Solution
First of all you must change permissions on your server machine with this command:
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
then edit in the /etc/ssh/sshd_config to this:
sudo sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
Run:
systemctl stop sshd.service
and Run:
systemctl enable sshd.service
then Run:
systemctl start sshd.service
after that:
systemctl status sshd.service
and check the output. If everything goes well you should have ssh services every time you boot from now on.
Answered By - Sajjad Serajzadeh Answer Checked By - David Marino (WPSolving Volunteer)