Top Nav

Archive | Reliable Penguin

Linux and open-source solutions.

Using SSHFS To Mount Remote Filesystem

If you need to do a lot of file operations against a remote ssh/sftp server then sshfs might be the perfect tool. sshfs is a FUSE filesystem that you can mount onto a local mount point. Once mounted you can manipulate the files as if there were local.

Here’s the project site:

http://fuse.sourceforge.net/sshfs.html

You might need to install with yum or apt-get:

After sshfs installed you can use it like this:

You’ll be prompted for a password unless you has keys setup with the remote server.

Now you can copy files to and from under mymount/.

0

Chrooted SFTP Users

Here’s the steps to create chrooted SFTP users.

1. Comment out the following line in /etc/ssh/sshd_config

2. Append the following in /etc/ssh/sshd_config

where USERNAME is the user and ChrootDirectory is the path that the user will be locked into. Add a new “Match User” stanza for each user that needs to be chrooted.  This allows each user to have a unique directory.

3. Restart SSH

4. Create the SFTP user group

5. Modify the user

SCP and SSH are not allowed with this setup but you could change the shell to allow them…

6. The highest directory in the chroot tree must be owned by user/group root

0

Add Storage To LVM/XFS Partition

Let’s assume that you have XFS formatted partition hosted on LVM named “/dev/vg1/gfs1” where “vg1” is the “volume group” and “gfs1” is the “logical volume”. You want to add an additional drive named “dev/xvdc” to the partition to increase storage. Here are the steps:

1. Partition the new drive with fdisk

2. Setup /dev/xvdc1 as an LVM physical volume:

3. Add /dev/xvdc1 to the LVM volume group:

You can show volume group detail to see the newly available storage:

Notice that “Free PE” is 100GB which is the size of our new /dev/xvdc drive.

4. Extend logical volume to use newly available storage:

5. Grow the XFS filesystem on “gfs1”:

And that’s it ..

Of course there are lots of possible variations on the process. For example maybe you don’t want to allocate all of the free space to one single logical volume but these steps should provide a good starting place.

 

 

0

GoAccess Web Log Analyzer

Here’s a great webserver log analysis tool. It’s lightweight, fast and runs from the command line on Linux:

http://goaccess.prosoftcorp.com/

Just download, build and run with something like:

I also like generating an HTML report with something like:

0

Monitor Web Site Files With Auditd

The Linux Auditing System and auditd are a great way to monitor who and when changes are made to the files in your website.  To install and configure follow these steps:

1. Install auditd and related utilities:

2. Make sure auditd is running:

3. Edit /etc/audit/auditd.conf and change:

This sets any action emails to go to your preferred address.

4. Edit /etc/audit/audit.rules and add a line like this to the bottom:

So if you website is located at:

Then a command like:

would setup auditing of write and attribute change requests. Events matching this rule would be tagged with the “mysite” key.

Audit logs go to:

 

 

 

 

 

 

 

 

0