Solved

Linux Security: Help I have lost SSH access to my server

Posted on 2013-06-15
6
802 Views
Last Modified: 2014-07-16
Dear Experts,
I have a stand alone server hosted by an external company.

Linux CENTOS.

We have suddenly lost SSH access.  We also cannot login with the root password through cPanel control panel.

We are told all the files and folders have been changed to the permission 777 which "breaks" the server.

Is this the final story or is there any way to get back control of the server?
Best Wishes,
Phil
0
Comment
Question by:PTRUSCOTT
6 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 39249791
You should use Putty to access your server via command line.

Yes, 777 is not just a terribly bad idea but if it can break many things.   In particular, if you have public-private key mechanism enabled, it would quit working if your .ssh folder and/or files in it have world write permissions.  They have to have as restrictive permissions as possible.

Certain other mechanisms like SELinux also disble access if permissions are too open.
If you made 777 for everything on the server, you need to either get backup to the old settings or if you don't have a good backup, reinstall anyway.

See if it would manually let you access though command line or through console.
0
 
LVL 1

Author Comment

by:PTRUSCOTT
ID: 39249815
When I try to use PuTTY.esxe with the old settings (root user name) and port 22.

I get the following error message:

PuTTY fatal error message:

"Server Unexpectedly closed network connection"

Is there some PuTTY configuration to get accesss in this situation?
Best Wishes,
Phil
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39249820
Do you have any other user besides root that you may use to login?  Once you get into the system, you can change user.

You need to use some utility to see if ssh is even up.  Do you have a Linux client or only Windows?

Use telnet to see if the port is advertised.
telnet server.com 22

Ping the machine to see if it is even running.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 76

Expert Comment

by:arnold
ID: 39249836
Console access is the only way.  Does the remote provider have an IP KVM that can be used to access the console?
Depending on the system maker, does it have DRAC, ILOM, LOM type of access?
It had to have been configured and the remote provider would ........

Can you go on site?

The remaining option is either have their support staff work on it if available, r have the system shipped to you,
0
 
LVL 21

Accepted Solution

by:
Mazdajai earned 500 total points
ID: 39249977
As other experts have mentioned, your only option is to try ssh in with other users and su to root.

But in the end the box still require a reinstall from a console because it is nearly impossible to fix the permission.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 40200795
Reinstall and restore from backups is probably the quickest way, But for info - rpm can restore ownership and permissions of OS files:

for RPM in $(rpm -qa); do rpm --setugids --setperms $RPM; done

Open in new window


But to be able to do that you have to log in and I think the login program needs to be setuid root which `chmod 777` will have broken. You may be able to get in in single-user mode, or boot from CD and fix enough program permissions to log in.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now