How to mount SFTP share in Linux machine

This could be implemented using both FUSE and SSHFS.

Download both from  http://fuse.sourceforge.net/sshfs.html

1. Install FUSE

package: fuse-x.tar.gz

Extract and install
#tar xvf fuse-x.tar.gz
#cd fuse-x
#./configure
#make
#make install

After successful installation, install SSHFS

package: sshfs-fuse-x.tar.gz

Extract and install
#tar xvf sshfs-fuse-x.tar.gz
#cd sshfs-fuse-x
#./configure
#make
#make install

Now we can use sshfs to mount sftp share. Before mounting, create mount point where the share to be mounted.

#mkdir /mnt/sftpshare

Mount command:  sshfs <username>@<sftpserver IP/host>:/<sftp_share_path> /<mountpoint>

Eg:
#sshfs testuser@192.168.1.2:/home/testuser /mnt/sftpshare/

This will prompt for password if user configured any password.

NOTE:  If you want to avoid prompting for password,then you should configure key based ssh login between these servers.

Verify the mounted partition using df command.

To mount this share directory in boot time, add the following entry in /etc/fstab

sshfs#testuser@192.168.1.2:/home/testuser     /mnt/sftpshare          fuse                   defaults        0 0

NOTE:     For unmounting this partition,we can use fusermount command as below
#fusermount -u /mnt/sftpshare/

Reference: http://www.coretimer.com/howtos/how-to-mount-sftp-share-in-remote-linux-machine/

Dump Mysql Tables

Often you have encountered problems while importing large databases via phpmyadmin. In that case, you can dump the mysql tables by using the following command.

for T in `mysql -N -B -e ‘show tables from database_name’`; do echo $T;    mysqldump database_name  $T > database_name_$T.gz ;    done

Now you can restore the tables one by one through phpmyadmin.

PTY allocation request failed on channel 0

Recently I tried to ssh into a guest in vmware. I was able to authenticate in the server and I was not able to access the console. I was getting the following error.

$ ssh x.x.x.x
The authenticity of host ‘x.x.x.x (x.x.x.x)’ can’t be established.
RSA key fingerprint is 1c:4d:1b:6g:d5:40:db:5b:46:7f:bb:17:b1:1b:41:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘x.x.x.x’ (RSA) to the list of known hosts.
root@x.x.x.x’s password:
PTY allocation request failed on channel 0

On checking the logs from the console, I found the following error.

sshd[2641]: pam_unix(sshd:session): session opened for user root by (uid=0)
sshd[2641]: error: openpty: No such file or directory
sshd[2641]: error: session_pty_req: session 0 alloc failed
sshd[2756]: pam_unix(sshd:session): session opened for user root by (uid=0)
sshd[2756]: error: openpty: No such file or directory
sshd[2756]: error: session_pty_req: session 0 alloc failed

I found that the device file ptmx was missing the server. Now I have to recreate the device file. I googled around for sometime and found the following solution.

$ sbin/MAKEDEV -d /dev ptmx

And it worked. I restarted SSH service and was able to login to the vmware guest. 🙂

Install APC in cPanel server

You can install APC (Alternative PHP Cache) in your cpanel server using the following steps:

# pecl install apc

Then add the extension in the php.ini file.

You can get the php.ini file by

# php –ini

Add the following line to it.

extension=”apc.so”

Then, retart apache service and you are good to go.

I encountered the following error while installation.

“checking whether the C compiler works… configure: error: cannot run C compiled programs.”

I made it working by the following:

# mount -o remount,exec,suid /tmp

Complete the installation and don’t forget to remount the tmp directory with noexec, nosuid options after the installation.

Subversion install error

You may get the following error while installing subversion:

root@server [/usr/src]# yum install subversion
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nluug.nl
* extras: ftp.nluug.nl
* updates: ftp.nluug.nl
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package subversion.i386 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
–> Processing Dependency: neon >= 0.25.5-6.el5 for package: subversion
–> Processing Dependency: libneon.so.25 for package: subversion
–> Processing Dependency: libapr-1.so.0 for package: subversion
–> Processing Dependency: libaprutil-1.so.0 for package: subversion
—> Package subversion.x86_64 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
–> Processing Dependency: libaprutil-1.so.0()(64bit) for package: subversion
–> Processing Dependency: libapr-1.so.0()(64bit) for package: subversion
–> Running transaction check
—> Package apr.i386 0:1.2.7-11.el5_5.3 set to be updated
—> Package apr.x86_64 0:1.2.7-11.el5_5.3 set to be updated
—> Package apr-util.i386 0:1.2.7-11.el5_5.2 set to be updated
–> Processing Dependency: libpq.so.4 for package: apr-util
—> Package apr-util.x86_64 0:1.2.7-11.el5_5.2 set to be updated
–> Processing Dependency: libpq.so.4()(64bit) for package: apr-util
—> Package neon.i386 0:0.25.5-10.el5_4.1 set to be updated
—> Package neon.x86_64 0:0.25.5-10.el5_4.1 set to be updated
—> Package subversion.i386 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
—> Package subversion.x86_64 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
–> Running transaction check
—> Package postgresql-libs.i386 0:8.1.23-1.el5_6.1 set to be updated
—> Package postgresql-libs.x86_64 0:8.1.23-1.el5_6.1 set to be updated
—> Package subversion.i386 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
—> Package subversion.x86_64 0:1.6.11-7.el5_6.3 set to be updated
–> Processing Dependency: perl(URI) >= 1.17 for package: subversion
–> Finished Dependency Resolution
subversion-1.6.11-7.el5_6.3.x86_64 from updates has depsolving problems
–> Missing Dependency: perl(URI) >= 1.17 is needed by package subversion-1.6.11-7.el5_6.3.x86_64 (updates)
subversion-1.6.11-7.el5_6.3.i386 from updates has depsolving problems
–> Missing Dependency: perl(URI) >= 1.17 is needed by package subversion-1.6.11-7.el5_6.3.i386 (updates)
Error: Missing Dependency: perl(URI) >= 1.17 is needed by package subversion-1.6.11-7.el5_6.3.i386 (updates)
Error: Missing Dependency: perl(URI) >= 1.17 is needed by package subversion-1.6.11-7.el5_6.3.x86_64 (updates)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.

The fix was to temporarily remove perl from the /etc/yum.conf exclude line and install subversion.

Add perl back to the /etc/yum.conf exclude line after subversion installation is completed in the system.

Ref: http://forums.cpanel.net/f42/please-help-me-install-these-encoders-204682.html

cPanel upcp error : Undefined subroutine

I have seen recent cPanel upgrade throwing errors shown below:

root@server [~]# /scripts/upcp
/scripts/upcp syntax OK
Running Futex Check/Fix……Done
Undefined subroutine &Cpanel::Update::automatic_updates_enabled called at /scripts/upcp line 273.

This can be fixed using below steps.

wget -O /root/updatenow.static http://httpupdate.cpanel.net/cpanels…datenow.static && perl /root/updatenow.static –manual

Now you will be able to upgrade the cPanel using upcp script.

/scripts/upcp –force

It worked for me.

Change MySQL database collation

You can change database collation from the WHM/cPanel.

1. Enter your WHM/cPanel and select phpMyAdmin.

2. Select the database you wish to manage.

3. Click on the Operations tab in the top menu of your phpMyAdmin

4.  At the bottom of the page you will see the collation option. Select a collation from the drop down menu and click on the Go button.

You are all set.

Download RPM packages using YUM

You can download packages via yum without installing/updating them. For this, you have to install a plugin named yum-downloadonly.Install the package using yum itself.

# yum install -y yum-downmloadonly

To download the packages, use the following commands:

# yum install package -y –downloadonly

The package will be downloaded and saved to the /var/cache/yum/ directory in this case.

To download it to the /usr/src/ directory, use the following:

# yum install package -y –downloadonly –downloaddir=/usr/src/

Now you can install the package using,

# rpm -ivh packagename.rpm

ClamAV ERROR: getfile: Can’t create new file

While running freshclam in servers, you may encounter this problem.

root@linux [~]# freshclam
ClamAV update process started at Fri Jun 11 19:23:37 2010
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.95.2 Recommended version: 0.96.1
DON’T PANIC! Read http://www.clamav.net/support/faq
ERROR: chdir_tmp: Can’t create directory ./clamav-c1140c4846ffa40c2678e2fdcd1221ee
WARNING: Incremental update failed, trying to download main.cvd
ERROR: getfile: Can’t create new file /usr/local/share/clamav/clamav-9a5f47dee827502d0a4e9cce6648aa3c in /usr/local/share/clamav
Hint: The database directory must be writable for UID 5127 or GID 5127
WARNING: Can’t download main.cvd from database.clamav.net

The issue is that the directory /usr/local/share/clamav/ is missing proper permissions. Run the following command and the freshclam command will work.

root@linux ~]# cd  /usr/local/share/; chown -R clamav.clamav clamav/
root@linux [/usr/local/share]# freshclam
ClamAV update process started at Fri Jun 11 19:23:56 2010
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.95.2 Recommended version: 0.96.1
DON’T PANIC! Read http://www.clamav.net/support/faq
nonblock_connect: connect timing out (30 secs)
Can’t connect to port 80 of host database.clamav.net (IP: 65.120.238.5)
Trying host database.clamav.net (208.72.56.53)…
Downloading main-52.cdiff [100%]
main.cld updated (version: 52, sigs: 704727, f-level: 44, builder: sven)
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Current functionality level = 43, recommended = 44
DON’T PANIC! Read http://www.clamav.net/support/faq
Trying host database.clamav.net (168.143.19.95)…
Downloading daily.cvd [100%]
daily.cvd updated (version: 11181, sigs: 95755, f-level: 51, builder: edwin)
Database updated (800482 signatures) from database.clamav.net (IP: 168.143.19.95)
root@linux [~]#

Hope this helps 🙂