Solved

prevent user from deleting .ssh/authorized_keys file

Posted on 2013-11-25
4
825 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

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!

Join & Write a Comment

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 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

20 Experts available now in Live!

Get 1:1 Help Now