Unable to start SSH: /dev/null is not a character device

Posted by admin     Category: VPS Management

The “/dev/null is not a character device” message occurs in a VPS when an upgrade is performed and the /dev/null turns into a regular file.

# /etc/init.d/sshd restart
Restarting Secure Shell server: sshd failed!
/dev/null is not a character device!.

The /dev/null should be a character device as per the Linux standards. To fix the issue, remove the file

# rm -f /dev/null

Create the character device

# mknod /dev/null c 1 3

The file should look like follows:

# ls -la /dev/null
crw-rw-rw- 1 root root 1, 3 Oct  1 11:42 /dev/null

Now restart the sshd service

# /etc/init.d/sshd restart
Stopping sshd:              [  OK  ]
Starting sshd:              [  OK  ]

How to secure the /tmp partition on a VPS with noexec,nosuid option?

Posted by admin     Category: VPS Management
How to secure the /tmp and /var/tmp partition on a VPS?

On a VPS, there are 2 ways to mount OR secure /tmp and /var/tmp partitions with the noexec,nosuid option. One way is to mount these partitions from the Node the VPS resides on.

1) Login to the Node server and execute the following command:

# vzctl set VEID --bindmount_add /tmp,noexec,nosuid,nodev --save
# vzctl set VEID --bindmount_add /var/tmp,noexec,nosuid,nodev --save

The “bindmount_add” option is use to mount the partition inside the VPS. The ‘VEID’ is the VPS ID you are working on.

2) The second option is to mount these partition from within the VPS itself. It is useful incase you don’t have access to the Node server. To mount /tmp and /var/tmp from within the VPS, execute:

# mount -t tmpfs -o noexec,nosuid,nodev tmpfs /tmp
# mount -t tmpfs -o noexec,nosuid,nodev tmpfs /var/tmp

To check the mounted ‘tmp’ partitions, execute

root@server [~]# mount | grep tmp
tmpfs on /tmp type tmpfs (rw,noexec,nosuid)
tmpfs on /var/tmp type tmpfs (rw,noexec,nosuid,nodev)

Related Links:

 How to Secure /tmp on Dedicated server?

How to auto-start a VPS on a host server/node reboot?

Posted by admin     Category: VPS Management

Sometimes, we need to reboot a host server/node for the new changes to take effect OR if it’s inaccessible. Many a times a VPS don’t auto-start itself once the host node comes online.  The reason is the ONBOOT parameter in the VPS configuration file. The “onboot” parameter decides whether to start the VPS automatically once the host node comes online.

If it’s set to ‘yes’, the VPS will start automatically.
If it’s set to ‘no’, we will have to start the VPS manually.

To make the changes, edit the VPS configuration file

vi /etc/sysconfig/vz-scripts/VEID.conf

search for

ONBOOT=”no”

and change to

ONBOOT=”yes”

This change will auto-start the VPS next time the host node is rebooted.

vzquota : (error) Quota on syscall for xxx: Device or resource busy

Posted by admin     Category: VPS Management

You may receive the following error message while starting a VPS:

root@server [~]# vzctl start VEID
vzquota : (error) Quota on syscall for id xxx: Device or resource busy
vzquota : (error)       Possible reasons:
vzquota : (error)       – Container’s root is already mounted
vzquota : (error)       – there are opened files inside Container’s private area
vzquota : (error)       – your current working directory is inside Container’s private area
vzquota : (error)       Use -v option to see currently opened file(s).
Running vzquota on failed for Container xxx

The error message indicates 2 things:

1) There are some files in open state inside the VPS private area. You can check if there are any open files by executing:

lsof 2> /dev/null | egrep ‘/vz/root/xxx|/vz/private/xxx’

where, xxx is the VPS ID. It will list the open files which you can close and start the VPS.

2) Your current working directory on the host server is inside the VPS’s private area i.e. the private area of the VPS is at /vz/private/xxx and your current working directory while starting the VPS is inside /vz/private/xxx.

Check the current working directory:

root@server [~]# pwd

if the working directory is inside the VPS’s private area, come out of that directory by just executing the command

root@server [~]#  cd

This will bring you out to the home directory of the root user and you will be able to start the VPS without any issues.

root@server [~]# vzctl start VEID

Error: Unable to execute bash: No such file or directory

Posted by admin     Category: VPS Management

You may receive “Unable to execute bash: No such file or directory” error message while starting a VPS and the result is the VPS fails to start. The reason is, either the binaries from /bin OR /usr/bin are missing OR corrupted.

To fix the issue, you either copy the directories /bin and /usr/bin from a working VPS OR from the OS template the VPS is using.

Solution:

1) Copy directories from a working VPS:

cp -p /vz/private/VEID1/fs/root/bin /vz/private/VEID/fs/root/ -R
cp -p /vz/private/VEID1/fs/root/usr/bin /vz/private/VEID/fs/root/usr/ -R

where,

VEID1 is the working VPS
VEID is the VPS in question

2) Copy directories from the OS template. The OS templates are stored under /vz/template/cache directory.

a) Extract the template file the VPS is using

cd /vz/template/cache/
tar -zxf os-templatename.tar.gz

b) Copy the directories to the VPS private area

cp -p /vz/template/cache/root/bin /vz/private/VEID/fs/root/ -R
cp -p /vz/template/cache/root/usr/bin /vz/private/VEID/fs/root/usr/ -R

Once copied, make sure you are out of the VPS private area and restart the VPS.

vzctl start VEID

It will re-calculate the quota of the VPS and will start the VPS.