Archive for the ‘ftp’ Category

How to change the FTP user path in cPanel

By default cPanel does not allow you to change the FTP path for your main account or sub-accounts, after creating the domain. But you can easily change it from the FTP user configuration files. Each cPanel user has a file in /etc/proftpd (yes, even if you use pure-ftp)

# cat /etc/proftpd/user
user:$1$vAYD1RJQ$U7pJmHJvT5dFL.kzoJ8f6/:509:508::/home/user:/bin/ftpsh
user_logs:$1$vAYD1RJQ$U7pJmHJvT5dFL.kzoJ8f6/:509:508:user:/home/.domlogs/user:/bin/ftpsh

As you can see, /etc/proftpd contains a file for each of the accounts on the server. Edit the file for the domain, and change the home directory.

user:$1$vAYD1RJQ$U7pJmHJvT5dFL.kzoJ8f6/:509:508::/home/user/myfiles:/bin/ftpsh

After editing save the file and then restart your pure-ftpd service
=-=-=-=–=-

421 Sorry, cleartext sessions are not accepted on this server.

Some times when you connect the webhost via FileZilla you may encounter this error message, because the FTP SSL encryption option will be incorrect.

Solution:-

Main >> Service Configuration >> FTP Server Configuration

TLS Encryption Support >> “optional”

On the FTP client use server type as

Host: domain or Ip

Port : 21

Server Type : FTPES -FTP over explicit TLS/SSL

Enable the passive port range for Pure-FTPd

vim /etc/pure-ftpd.conf configuration file

enable the passive port range

PassivePortRange 30000 65000

Save the pure-ftpd.conf file and restart FTP service.

Enable the passive ports range in your server firewall
-=-=-=-=-

Reference : http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/FTPPassiveMode

Changing FTP password of all accounts in a cPanel server.

Here is a cPanel script [chpass] to reset each user’s password. Its syntax is as follows

/scripts/chpass

After running the script always run the following script

/scripts/ftpupdate

Using the above cPanel script I have created my own script to change all users password in one shot.

Script:

—————————
#/bin/bash
cat /etc/trueuserdomains | sort -t” ” -k2 > LIST.txt
exec 7 LIST.txt
for i in `cat /etc/trueuserdomains | awk ‘{ print $2 }’ | sort`; do
read > pass
sleep 1
done
/scripts/ftpupdate

—————————

What actually this script is doing?

01. Makes a sorted list of ‘/etc/trueuserdomains’ [sort with usernames] in a file ‘LIST.txt’
02. A File Descriptor opened for ‘LIST.txt’
03. Opened a for loop to itarate each users in ‘/etc/trueuserdomains’
04. Read the first line in the FD and remove the same on each iteration
05. Store a date format in a variable for generating password
06. Store a part of user name, say from third character of the name to last character, in variable for complicating the generated password
07. Executing the cPanel password changing script with appropriate parameters
08. Outing the information [Domain Name, User Name and New Password] to a file named “pass” on each iteration
09. Making a delay of 1 second on each iteration
10. Ending the for loop
11. Running cPanel password synchronization script.
==============================

How to Limit FTP connections from the same IP address? (pure-FTP)

# Maximum number of sim clients with the same IP address

MaxClientsPerIP 8

1. Open the pure-FTP configuration file.

vim /etc/pure-ftpd.conf

2. Search for the line “MaxClientsPerIP” and change the value to a required one. By default the value is 8. It is not recommended to increase the value for security reasons.

3. Restart FTP service using the command given below.

/etc/init.d/pure-ftpd restart

—————————————->

Unable to login to FTP

#ftp linuxtechme.wordpress.com
Connected to linuxtechme.wordpress.com.
220 Microsoft FTP Service
User (linuxtechme.wordpress.com:(none)): admin
331 Password required for admin.
Password:
530-User cannot log in, home directory inaccessible.
Win32 error: Access is denied.
Error details: Authorization rules denied the access.
530 End
Login failed.
ftp> quit
221 Goodbye.

Make sure that IP of domain hasn’t pointing to wrong directory in IIS. Correct it if necessary and reconfigure ftp with

cd %Plesk_bin%

\Plesk\admin\bin>ftpmng.exe –remove-all
\Plesk\admin\bin>ftpmng.exe –reconfigure-all

——————————>

Unable to login to a domain via FTP

Symptoms
Login to domain.com via FTP fails for all users. The following error message is displayed:
Cannot log in, home directory inaccessible

Cause
There could be several reasons. This error occurs if:

1. The host name is longer than 15 symbols.

2. The domain resolves to a different IP than the one which has been configured in Plesk.

3. The FTP server configuration is broken.

Resolution
1. To change the host name ,right-click the My Computer icon and choose Properties. Select the Computer Name tab, then click the Change button. Specify the computer name as desired and click OK. When done, restart your computer.

2. Please check if domain.com resolves to the same IP it has been configured for in Plesk. You can use the following command :

nslookup yourdomain.com

The returned IP should be the same as the one configured in Plesk for the domain.

3. If the name of your server is shorter than 15 symbols and the domain resolves to the proper IP, it could mean that something is broken in the FTP configuration.

You should follow the steps below to fix the issue:

a. For versions 8 and 9 only: Repair permissions on the home folders of problem domains. This can be done using the Control Panel:

Plesk , domains, mark problem domain, Click on Check permissions

b. Re-configure the FTP configuration using the Plesk command line tool ftpmng.exe as follows:

Note: The below commands will not affect functioning of your Web (HTTP/HTTPS) sites. However any custom FTP configuration will vanish.

Remove your domain entry from FTP server configuration:
“%plesk_bin%\ftpmng.exe” –remove-vhost –vhost-name=yourdomain.com

Add your domain vhost entry into FTP server configuration and reconfigure it:
“%plesk_bin%\ftpmng.exe” –reconfigure-vhost –vhost-name=yourdomain.com

c. If this issue happens to every domain, you can repair the FTP configuration for all domains using the following commands:

Note: The below commands will not affect functioning of your Web (HTTP/HTTPS) sites. However any custom FTP configuration will vanish.

Remove all domain entries from FTP server configuration:
“%plesk_bin%\ftpmng.exe” –remove-all

Add all domain entries into FTP server configuration and reconfigure them:
“%plesk_bin%\ftpmng.exe” –reconfigure-all
==================================>
Reference : http://kb.parallels.com/en/549

Login via FTP fails with “530 Login incorrect” error

Symptoms
I am trying to access the Parallels Plesk Panel (PP) server via FTP using the domain of the FTP user or webuser, but I get the following error:

530 Login incorrect.
Login failed.
421 Service not available, remote server has closed connection

Cause
This error may be caused by an incorrect user name/password pair. Also, this error occurs in cases where the FTP user does not have enough permissions to access their home directory, or this directory does not exist at all.
Resolution
Make sure that the right user name and password are used. To be sure, you can set a new password for the problem user through the PP Control Panel and try to log in via FTP again.

Check that the user’s home directory exists and that it is accessible by the user. For example, assume that the “username” user cannot log in via FTP.

– Log in to the PP server as the “root” user

– Check where the home directory for this user is:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow ` psa -e ‘select home from sys_users where login=”username”‘
+——————————+
| home |
+——————————+
| /var/www/vhosts/domain.com |
+——————————+

– Compare this directory with the one from /etc/passwd (they should match):
# grep ‘^username:’ /etc/passwd
username:x:10001:2524::/var/www/vhosts/domain.com:/bin/false

If they do not, rename the user to any new name through the PP CP, and then rename it back. This should fix the problem.

– Check if this directory exists and has the right permissions:
# ls -lad /var/www/vhosts/domain.com
d——— 14 root root 4096 2008-02-22 11:50 /var/www/vhosts/domain.com

– Correct permissions if needed:
# chmod 755 /var/www/vhosts/domain.com

– Try to log in via FTP again.
==========================================>
Reference : http://kb.parallels.com/en/4647

This is a very common error while accessing ftp even though you entered the correct login details. This is because ftp passwords and cpanel passwords are stored in separate locations and sometimes the ftp passwords wont get updated when you update cpanel passwords. To resolve this issue do the following steps.

1. Switch FTP from Pure-ftpd to Proftpd in WHM > FTP Configuration switch it back to again.
2. Synchronize FTP passwords using Main >> cPanel >> Synchronize FTP Passwords option in whm.
3. Make sure that the local machine IP address isn’t blocked in server firewall.
4. Restart FTP server using Main >> Restart Services >> FTP Server (ProFTPd/PureFTPd) option.

Or from shell

1. /scripts/ftpupdate
2. /etc/init.d/pure-ftp restart
================================================

This Shell script will search the server logs on daily basis and will email you the successful Ftp Logins of the day.
The ftp logs are saved in the /var/log/messages file as by default there is no separate log file for Ftp in Linux.
Create a file /home/script/ftplogins.sh and paste the below code:
#!/bin/bash
#Retrieve the current date
CUR_DATE=`date +”%b %e”`
#Create a temporary file to store the logs
touch /tmp/out.txt
echo “List Follows” > /tmp/out.txt

#Search the successful attempts and save in the temporary file
/bin/grep “$CUR_DATE” /var/log/messages | grep pure-ftpd | grep logged >> /tmp/out.txt
#Email the contents of the file to your email address
/bin/mail -s “Successful Ftp Login Attempts on ‘$CUR_DATE’” youremail@yourdomain.com < /tmp/out.txt
Save the file. You now have to schedule a cron to execute the file once in a day to search logs. Edit the cron file
crontab -e
and add the following cron job
59 23 * * * /bin/sh /home/script/ftplogins.sh
Note:
1) This script will work with Pure-Ftpd server. You will have to edit the search string a bit according to your Ftp server.
2) If you copy/paste the script as it is in shell, the single and double quotes may change to dots (.) so make sure you correct them before executing the script.
============================================================================