Accidentally changed ownership-unable to SSH into server.

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Accidentally changed ownership-unable to SSH into server.
# 1  
Old 04-25-2013
Question Accidentally changed ownership-unable to SSH into server.

Hi All,

Accidentally changed ownership of /var directory as root Smilie thinking that I am changing ownership of var directory in other location in the file systemSmilie.Now unable to SSH into the serverSmilie.
By gods grace I was able to regain the access again as server was in control of me at that time.Other wise hell would have broke down.Smilie

Is there any way I can set a message to be displayed a warning when I am changing the owner ship from root to some thing else for a particular directory .Smilie.I have tried upon all the ACL but didnt get worthy idea .
# 2  
Old 04-25-2013
I would setup a program like monit, or conary. Basically these are programs that will set file permissions or setting back to what they are where. If your core files are changed from the baseline, then it will email you. If you have it set up it will change them back after a certain time.
This User Gave Thanks to bitlord For This Post:
# 3  
Old 04-26-2013
Thanks for the suggestion .But I can not afford to add up one more mail demon to the running server .( Security reason's) .It will be a good thing to run a simple script to check out this thing and echo a message " The file permissions or ownership have been modified for the "...." directory ".
# 4  
Old 04-26-2013
The program could most likely be setup not to not email you. The email is to warn you about what the program is about to do. It would be bad if the program is changing things in the middle of a install. Usually you would turn off the program before system maintenance.
This User Gave Thanks to bitlord For This Post:
# 5  
Old 04-26-2013
Is there a way that I can Just take the logic in the code for checking ownership and permission in code so that i can make into a simple script rather than installing it in total..as I dnt have the full set of permissions for installing as most of the servers are in remote client location
# 6  
Old 04-26-2013
Rather than altering chown, or invoking widespread changes to your filesystem, you could make a chown function which you put in root's ~/.profile or equivalent:

Code:
chown() {

        # Get rid of switches
        while [ "${1:0:1}" = "-" ]
        do
                OPTIONS="$OPTIONS $1"
                shift
        done

        for FILE in "$@"
        do
                set -- `ls -l "$FILE"`
                if [ "$3" = "root" ]
                then
                        echo "ERROR altering file/folder owned by root"
                        return 1
                fi
        done

        echo /usr/bin/chown $OPTIONS "$@"
}

Remove the 'echo' once you've tested and are sure you want. And be careful testing it in case you call the real chown by accident! Run it on something harmless.

This won't catch everything modified by a chown -R.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Unable to ssh or login to AIX server

We are having occasional problems accessing some AIX servers. When this happens we cannot ssh to the server in question or login via HMC console terminal window. We can ssh some commands to the server and get responses but other commands just hang, ssh serverA date returns the date, ssh serverA... (5 Replies)
Discussion started by: Kierong
5 Replies

2. UNIX for Advanced & Expert Users

Unable to ssh to remote server

Hi, I have two SunOs sparc servers mac1 and mac2. I have exchanged keys between them inorder to passwordless login ssh from mac1 to mac2. However, it is failing after authentication. Part of the debug is as below. Please suggest whats wrong and how do i fix that!! Note: i do not have... (1 Reply)
Discussion started by: mohtashims
1 Replies

3. HP-UX

Unable to ssh to server in HP-UX.

Hello Experts, I'm Unable to ssh to server after killing few processes on /opt filesystems. Can you please help me to resolve this. (3 Replies)
Discussion started by: purushottamaher
3 Replies

4. Shell Programming and Scripting

Script to echo "File permissions or ownership changed from required " when accidentally changed.

Hi All, I have to work in the late nights some times for server maintenance and in a hurry to complete I am accidentally changing ownership or permission of directories :( which have similar names ( /var in root and var of some other directory ).:confused: Can some one suggest me with the... (1 Reply)
Discussion started by: shiek.kaleem
1 Replies

5. Emergency UNIX and Linux Support

Accidentally Changed File Ownership to Include a "Comment" [AIX]

Hi. I've had a little mishap. To cut a long story short, I've accidentally recursively ran chown on a directory (actually a bunch of 'em). Not a problem in itself, but I had a slight error in the code I used to get the list of directories and ended up with a comment in the file ownership. ... (15 Replies)
Discussion started by: Scott
15 Replies

6. Red Hat

unable to connect remote server using ssh

hi all i am unable to connect remote server using ssh but i am able to ping the server ssh service is running. (5 Replies)
Discussion started by: nikhil kasar
5 Replies

7. UNIX for Advanced & Expert Users

SuSE-11 Ownership of files having root got changed

Hi Experts, I have create a new user with uid and gid as 0 in SuSE-11 Server. After that all the files having root owner ship are showing as new user name as owner. If I login as root, and type 'id' command, it also shows the new user. Sample output from my server. host:~ # id uid=0(test)... (4 Replies)
Discussion started by: vipinable
4 Replies

8. OS X (Apple)

I accidentally changed to only write permission on /usr/bin... please Help!

I accidentally changed to sudo chmod a=w to my /usr/bin folder on my macbook with OS 10.5.8... Please help! I can't even get into a terminal correctly cause it displays: -bash: uname: command not found -bash: cut: command not found -bash: uname: command not found -bash: cut: command not found... (6 Replies)
Discussion started by: scaryMac23
6 Replies

9. UNIX for Advanced & Expert Users

/etc ownership was changed via chown

Hello all: I have a couple of boxes located in New York, both running SunOS 5.6. I, unfortunately, am located in Pittsburgh and do not have console access to these boxes. A co-worker was attempting to build a user account in one of these boxes, and mistakenly did a: chown username * ... (5 Replies)
Discussion started by: cdunavent
5 Replies

10. Solaris

changed shell of the root accidentally

Hi All, I have changed the shell of the root accidentally to /sbin/bash :mad: How do I change that? :( To change that I need to go to ok prompt I think, and there I need to mount the root file system in order to make changes to the respective file. Can any one please suggest how do I do... (4 Replies)
Discussion started by: pintu_asim
4 Replies
Login or Register to Ask a Question