Thursday, June 26, 2014


SkyHi @ Thursday, June 26, 2014

Having an apache segmentation fault on your server can drive you crazy trying to solve it… So, I’m gonna explain you how I figured out what was causing the last apache segfault I had.
My server was running under Debian Squeeze, with Apache 2.2 and PHP 5.3, and I got randomly segmentation faults:
I supposed the problem was on some php extension, so I deactivated some of them…but the problem was still there :(
After spending a lot of time looking for what was causing it, I decided to debug apache with gdb. I installed it through backports because I needed an upper version than gdb 7.0 (7.0.1-2 is the current version on squeeze stable repository) otherwise I got this: “warning: The current binary is a PIE (Position Independent Executable), which GDB does NOT currently support. Most debugger features will fail if used in this session.” when I was trying to debug apache:
Well, I had the debugger installed, but I also needed the php and apache debug symbols:
Once I had installed all I needed, I configured apache to create a core dump file every time it had a segfault by adding in /etc/apache2/httpd.conf the following line:
Previously, I had created the /tmp/apache-coredumps directory
By default, my system core file size was 0, so I had to change it through ulimit:
I restarted apache, and I only had to wait for the next Segmentation fault… and I didn’t have to wait too much …
Then, as the message said, I had a core file in /tmp/apache-coredumps, and I was closer to finding out what was causing segfaults :)
Therefore, it was time to use gdb:
I had a problem with php as I thought, and I was able to find more information about it. And after Googling for a few minutes, I found there is a bug with the PHP and APC version that I was using! (more info here)
After that, I could solve the problem and until now I haven’t got more segfaults on this server :)
Using gdb will not solve your segmentation faults, but at least, you will be able to figure out what’s causing it, and you’ll get more info to solve it.


Friday, April 11, 2014

Certificate issue on remote desktop

SkyHi @ Friday, April 11, 2014

he remote computer could not be autherticated due to problems with its security certificate. it may be unsafe to proceed.

Windows Vista/2008+ secures the remote connection with a self signed certificate. This certificate only exists on the server and until you import it on your machine, you will get a warning.
How to fix -
You can view the certificate then import it to your local store and it will be trusted.
The reason for this is simply in a large corporate environment, with their own certificate authority, they can give every machine a certificate, and, as the root will be trusted, all computers will "know" each other automatically.

Tuesday, March 25, 2014

Mounting a remote linux directory onto a windows machine for editing files

SkyHi @ Tuesday, March 25, 2014


In many cases it can become cumbersome to transfer files to and from a droplet. Imagine a development usage scenario where you are coding apps remotely and find yourself uploading a script repeatedly to your virtual server to test. This can become quite a hassle in a very short period of time. Luckily there is a way to mount your VPS file system to your local computer so you can make changes on the fly and treat your droplet as local storage. In this article, we will show you how to do exactly that.

Installing SSHFS

On Ubuntu/Debian

SSHFS is Linux based software that needs to be installed on your local computer. On Ubuntu and Debian based systems it can be installed through apt-get.
sudo apt-get install sshfs

On Mac OSX

You can install SHFS on Mac OSX. You will need to download FUSE and SSHFS from the osxfuse site

On Windows

To install SSHFS in Windows you will need to grab the latest win-sshfs package from the google code repository. A direct download link can be found below. After you have downloaded the package, double click to launch the installer. You may be prompted to download additional files, if so the installer will download the .NET Framework 4.0 and install it for you.

Mounting the Remote File System

The following instructions will work for both Ubuntu/Debian and OSX. Instructions for Windows systems can be found at the bottom of the tutorial.
To start we will need to create a local directory in which to mount the droplet's file system.
sudo mkdir /mnt/droplet <--replace code="" droplet="" prefer="" whatever="" you="">
Now we can use sshfs to mount the file system locally with the following command. If your VPS was created with a password login the following command will do the trick. You will be asked for your virtual server's root password during this step.
sudo sshfs /mnt/droplet
If your droplet is configured for login via ssh key authorization, you will need to tell sshfs to use your public keys with the following command. You will be asked to enter the passphrase you used during the creation of your keys with ssh-keygen.
sudo sshfs -o IdentityFile=~/.ssh/id_rsa /mnt/droplet
Now you can work with files on your droplet as if it were a physical device attached to your local machine. For instance, if you move to the /mnt/droplet directory on your local machine you can create a file locally and the file will appear on your virtual server. Likewise you can copy files into the /mnt/droplet folder and they will be uploaded to your droplet in the background.
It is important to note that this process provides only a temporary mount point to your droplet. If the virtual server or local machine is powered off or restarted, you will need to use the same process to mount it again.

Unmounting the Remote File System

When you no longer need the mount point you can simply unmount it with the command
sudo umount /mnt/droplet

Permanently Mounting the Remote File System

SSHFS also allows for setting up permanent mount points to remote file systems. This would set a mount point that would persist through restarts of both your local machine and droplets. In order to set up a permanent mount point, we will need to edit the /etc/fstab file on the local machine to automatically mount the file system each time the system is booted.
First we need to edit the /etc/fstab file with a text editor.
sudo nano /etc/fstab
Scroll to the bottom of the file and add the following entry /mnt/droplet
Save the changes to /etc/fstab and reboot if necessary.
It should be noted that permanently mounting your VPS file system locally is a potential security risk. If your local machine is compromised it allows for a direct route to your droplet. Therefore it is not recommended to setup permanent mounts on production servers.

Using Win-SSHFS to Mount Remote File Systems on Windows

After launching the win-sshfs program, you will be presented with a graphical interface to make the process of mounting a remote file share simple.
  • Step 1: Click the Add button in the lower left corner of the window.
  • Step 2: Enter a name for the file share in the Drive Name field.
  • Step 3. Enter the IP of your droplet in the Host field.
  • Step 4. Enter your SSH port. (Leave as port 22 unless you have changed the SSH port manually).
  • Step 5. Enter your username in the Username field. (Unless you have set up user accounts manually you will enter root in this field).
  • Step 6. Enter your SSH password in the password field. (Note on Windows you will need to have your droplet configured for password logins rather than ssh-key-authentication).
  • Step 7. Enter your desired mount point in the Directory field. (Enter / to mount the file system from root. Likewise you can enter /var/www or ~/ for your home directory).
  • Step 8. Select the drive letter you would like Windows to use for your droplets file system.
  • Step 9. Click the Mount button to connect to the droplet and mount the file system.
Now your virtual server's file system will be available through My Computer as the drive letter you chose in step 8.

Usage of the Remote Mount Point

The remote mount behaves similarly to locally mounted storage: you are able to create, copy, move, edit, compress or perform any file system operations you would be able to do on the droplet, but you are not able to launch programs or scripts on the remote server.
One typical usage of this would be if you host a website on your VPS and need to make changes to the website on a regular basis. Mounting the file system locally allows you to launch whatever code editor, IDE, or text editor you wish to edit the site, and any changes you make will reflect on the virtual server as soon as they are made on your local machine.
Similarly, on droplets used for testing purposes of coding projects, it allows for much simpler code modifications which can be tested immediately without the need to modify the code locally as well as remotely (and eliminates the hassle of uploading new copies of files for small code changes).


Friday, December 20, 2013

Configuring postfix to forward all email to a smtp gateway

SkyHi @ Friday, December 20, 2013


Suppose you want all your web servers to locally send all email (maybe from your contact forms, or whatever) to a real smtp gateway. If you're running postfix as your mta, this is quite easily to achieve.


In your file (usually /etc/postfix/ or /usr/local/etc/postfix/, specify your transport maps:
  1. transport_maps =  hash:/etc/postfix/transport  
And in your transport file (usually /etc/postfix/transport or /usr/local/etc/postfix/transport), specify your gateways per domain. This allows you to specify with regular expressions which emails go where. In this case, an asterisk specifies every domain (the transport file allows very complex setups, this is of course an extreme and trivial example):
  1. *      
Then invoke postmap to regenerate the transports db, and reload postfix:
  1. # postmap hash:/etc/postfix/transport  
  2. # postfix reload  
That should do it. All email generated in this host should now be forwarded to the smtp gateway. Remember to configure your smtp gateway to accept mail from all the hosts that will forward emails to it.

Volts / Watts / Amps Converter

SkyHi @ Friday, December 20, 2013
How to use this tool:
Watts = Amps x Volts
Watts is also known as volt-amps and is typically used in conjunction with AC power circuits. Fill in any of the two fields to find the value of the third.
Example 1
You have a 12 Volt power supply that delivers 1 Amp of current. Fill in the Volts and Amps fields to find the Watts.
Example 2
The AC24-40 power supply is a 24V AC power supply that can power up to 40 VA.
  1. Enter 24 under volts
  2. Enter 40 under watts
  3. Click calculate
  4. You get 1.66 in this example.
Thus, the AC24-40 can supply up to 1.6 Amps at 24V AC.


Thursday, September 12, 2013

How to detect the physical connected state of a network cable/connector?

SkyHi @ Thursday, September 12, 2013
You can use ethtool:
$ sudo ethtool eth0
Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: umbg
    Wake-on: g
    Current message level: 0x00000007 (7)
    Link detected: yes
To only get the Link status you can use grep:
$ sudo ethtool eth0 | grep Link
    Link detected: yes


Friday, August 30, 2013

mount error(115): Operation now in progress ... CIFS VFS: cifs_mount failed w/return code = -115

SkyHi @ Friday, August 30, 2013
Trying to mount a CIFS path in Ubuntu and getting:
mount error(115): Operation now in progress
First thing to try is to look into /var/log/syslog:
Feb  9 14:08:29 ldap kernel: [143452.140157] CIFS VFS: Error connecting to socket. Aborting operation
Feb  9 14:08:29 ldap kernel: [143452.140492] CIFS VFS: cifs_mount failed w/return code = -115
Socket error, we know what this is right? IP or port. Ping for domain/IP or Telnet to test port:
ping IP
telnet IP 445
My case? Telnet was timing out, port closed for IP in firewall.