Category: Linux

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/.

Read More »

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

Read More »

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

Read More »

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:

               

Read More »

Fix Completion In Shell On Ubuntu

Sometimes with a new user on Ubuntu I find that filename auto-completion is missing in the shell. I found two issues that cause this: 1. Ubuntu sets new users to /bin/sh which is a very limited shell. So first step is to change the user to /bin/bash:

2. The /etc/bash.bashrc has filename completion disabled by default. Edit this file and un-comment the appropriate lines. Here’s what it looked like on one server:

So I changed to:

Upon login the new user should now have filename completion features. Also note that by default “vi” is handicapped. Here’s how to upgrade to a full feature set: http://blogs.reliablepenguin.com/2013/10/25/fix-vi-ubuntu

Read More »

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.