Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Centos 5.9 server which I have previously configured to access via SSH key login and this has been working fine for many months. I recently had to have an issue resolved remotely which required me re-enabling the root login temporarily. After this was resolved I then disabled root login by setting "PermitRootLogin no" in the sshd_config file, however, I also set "Password authentication no" and I think this is where I've messed things up. After doing this I can no longer log in to the server, I just get the message:

Permission denied (publickey,gssapi-with-mic).

I've basically got no other way of accessing the server via SSH so I've come unstuck! I'm fairly certain it's because I've set the Password authentication to no that is the problem, I haven't changed any other settings on the server which should be affecting the keys that previously worked fine.

How can I regain access to the server via SSH?

share|improve this question
    
What is your question ? –  Iain Feb 18 at 13:03
    
Sorry, edited my post with an explicit question. –  Rick Curran Feb 18 at 13:08
1  
You need console access, of course.. –  Aaron Copley Feb 18 at 13:13

3 Answers 3

up vote 5 down vote accepted

You need console/out of band access. Contact your hosting provider or schedule a visit or whatever.

share|improve this answer
    
Thanks. I'm not sure if there is any console access available, the server is actually a VPS running on a cloud-based server cluster. I've enquired with my server support to see if there is anything available. –  Rick Curran Feb 18 at 17:16

Login via your remote console, rescue disk, etc, depending on what your provider gives you.

If you only want to be able to ssh to root with keys, and not with passwords, then set:

PermitRootLogin without-password
share|improve this answer
    
Thanks, I'll keep that in mind once I get back into the server :) –  Rick Curran Feb 18 at 17:18

I looked online and there are VPS consoles that will enable you access to your server. Your cloud provider should be able to help you with this. After you get back into the server copy a "known good" copy of the sshd_config file, over top your existing file. Are you sure you disabled all other methods of connecting to your server?

share|improve this answer
    
Thanks, unfortunately there was no other means for me to get into the server, but fortunately my VPS provider had the ability to roll back the change for me so I'm back in now. –  Rick Curran Feb 21 at 9:33
    
I'm glade you are now able to get back on. I guess they had your VM backed up and just did a restore. If I where you I would work on setting up remote consoles on your servers. –  Cyberninja Feb 21 at 21:27
    
My VPS provider uses the Microsoft Hyper V platform for their servers so I think this gives them some way of rolling back changes. I have asked them to explain how they were able to revert the change I'd made to the sshd_config file. Most importantly in future I will avoid closing my existing SSH window when editing any of these configs to avoid locking myself out again. :) –  Rick Curran Feb 24 at 10:04
    
I don't know much about Hyper V as I'm a UNIX/Linux admin. I'm sure there is a way to get console, you can get one with VMware. In the future you always have a console window up when making changes, because even if you had a window up you can still be boot off the server after making changes to SSH or any other communication service. –  Cyberninja Feb 24 at 14:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.