Solved

prevent user from deleting .ssh/authorized_keys file

Posted on 2013-11-25
4
844 Views
Last Modified: 2013-12-19
We have setup an Ubuntu server for the purpose of provide SFTP accounts for a number of users. Each user has an account and can upload files to their respective home directories. We are using vsftpd and key pairs. The users do not have SSH access.

The issue I'm having is that I'd like to prevent users from modifying or deleting the authorized_keys file in their /home/user/.ssh directory.

Ideally, we'd prefer that they not see or modify these files and directories, all under the /home/user directory:

.bash_logout
.bashrc
.profile
.ssh

And instead, they would only access the /home/user/files directory.

Any suggestions on how to accomplish this?

Thanks.
0
Comment
Question by:TrinitySEM
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39675025
rbash
0
 
LVL 10

Accepted Solution

by:
Luxana earned 500 total points
ID: 39675042
Hi,

make your files immutable. Check this example:

$ echo test > file1
$ cat file1 
test
$ su
Password:  
# chattr +i file1 
# exit
$ cat file1 
test
$ rm file1 
rm: remove write-protected regular file `file1'? y
rm: cannot remove `file1': Operation not permitted

Open in new window


From the above you can see that user still can read this file but will not be able to modify it or remove it.

hope this helps...
0
 

Author Comment

by:TrinitySEM
ID: 39724617
Thank you. That worked.

One issue is that I created a test file with the root user account and now that user can't delete the file. Any thoughts on how to remove?

Thanks again.
0
 
LVL 10

Expert Comment

by:Luxana
ID: 39728681
as  root change ownership of this file:

chown username.username /home/username/file
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 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