How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

March 20, 2014

Create an FTP user on a cPanel server from shell

Filed under: Linux — Tags: , , , , , , — admin @ 11:18 am

Well today I wanted to make a script to automatically create some user for an account from shell, that’s because they where to many to make them manually from cpanel/whm . Also this command work on your server even if you have pure-ftpd or proftpd ) , because the cpanel keep the virtual user information into /etc/proftpd/ ( also there is a all user/password into /etc/proftpd/passwd.vhosts ) .

So , how to add a ftp user from shell ?
Well the syntax is :
/usr/local/cpanel/bin/proftpd_passwd -a ::::::

So first of all we have to know the uid and gid for this we can grep the passwd file.
grep /etc/passwd

Example how to add a username for matrafox system user :
grep matrafox /etc/passwd
matrafox:x:xxx:yyy::/home/matrafox:/usr/local/cpanel/bin/noshell
/usr/local/cpanel/bin/proftpd_passwd matrafox -a testuser:testpassword:xxx:yyy:matrafox:/home/matrafox/public_html:/sbin/nologin

If you want to detele a user the syntax is:
/usr/local/cpanel/bin/proftpd_passwd -d

Also if you manually edit a file you should run also the command so changes to take effect :
/usr/local/cpanel/bin/ftpupdate

March 10, 2014

rpm – Find out what files are in my rpm package

Filed under: Linux — Tags: , , , — admin @ 10:59 am

Use following syntax to list the files for already INSTALLED package:
rpm -ql package-name

Use following syntax to list the files for RPM package:
rpm -qlp package.rpm

March 7, 2014

qmail mail forwarding aliases

Filed under: Linux — Tags: , , — admin @ 1:29 pm

Email forwarding for your domain is controlled by special files you put in your home directory. All of these files begin with “.qmail-” and end with the username.

For example, joe@yourdomain.com would be controlled by the file “.qmail-joe”. This is a text file, containing the list of destination addresses, one address per line.

If the file is empty (0 bytes), mail for that user will be delivered to you. (You need to be sure the file is zero bytes, an empty file of just one blank line will not work.)

These files must be uploaded in ASCII mode.

There is one special username called “default” (use the file “.qmail-default”) that will forward all mail for your domain that is not already specified with its own forwarding file.

If this file is 0 bytes, all mail going to anybody at your domain will be delivered to you.

If you have a separate POP3 account for your domain, you need to forward the mail to that user. For example, a POP3 account named “jack” needs to have a “.qmail-jack” file with just the word “jack” inside.

If you don’t do this, mail for jack will be delivered to the address given in the “.qmail-default” file (or to yourself if it’s empty). If you don’t have a default forwarding and don’t set the forwarding for jack, mail to jack will be returned with a “user unknown” error message.

For email addresses with a dot in it (first.last@yourdomain.com), you need to change the . to : in the “.qmail-” file.
For example, joe.blow@yourdomain.com is controlled by the file “.qmail-joe:blow”.

Be careful to never have any blank lines or spaces in a “.qmail-” file, and always put each destination address on a different line.

So for example for user test@example.com if we want to forward all e-mail and keep a copy we will have the file .qmail-test with this into example directory :
&test@test2.com
./test/Maildir/

February 26, 2014

how to delete bounce emails for non existent users vpopmail

Filed under: Linux — Tags: , , , — admin @ 5:28 pm

The last parameter in the .qmail-default file tells vdelivermail what to do with non-matching emails. The default is to bounce the email back to the sender. But you can also delete it instead.

update your .qmail-default file from something like this:
| /home/vpopmail/bin/vdelivermail ” bounce-no-mailbox

to something like this:
| /home/vpopmail/bin/vdelivermail ” delete

February 20, 2014

qmail and qmail-default

Filed under: Linux — Tags: , — admin @ 2:39 pm

Overview and Configuration

Qmail is a powerful e-mail package that allows for a great deal of custom e-mail processing and other settings.

Normally, qmail recipes are stored in your account’s home directory, /usr/home/USERNAME. However, to make e-mail handling more reliable, our custom qmail setup has an additional directory to store e-mail recipes: /var/rules/USERNAME. By not having the e-mail recipes in the home directory, it is easier to keep the e-mail files intact.

It should be noted that /var/rules/USERNAME is automatically maintained by the Account Control Center (ACC). You should not put custom recipes there, because they will be overwritten. However, you can set up rules in the ACC, and then check /var/rules/USERNAME to review the format of each recipe.

Filename Structure and Rule Matching

All user configuration files used by qmail start with “.qmail”. A normal account at pair Networks will have two main files:

.qmail
.qmail-default

The .qmail file controls e-mail sent to your username@pair.com, while .qmail-default controls e-mail sent to any domain name in your account. The .qmail and .qmail-default files can reside in the home directory or in /var/rules/USERNAME.
.qmail is not required, but you must have a .qmail-default file (or else mail to your domain name will bounce). For this reason, if there is no .qmail-default file in the home directory, the system automatically creates one for you in /var/rules/USERNAME.

Qmail rules match e-mail addresses from the most specific match, to the least specific. If no match is found, the .qmail-default rule is used.

Please note that if you create .qmail* files locally and FTP them to the server, you must use ASCII mode for the file transfers.

A scenario should help to clarify this and allow it to be explained more easily. In this example, “username” is the account username, and “example.com” will be the domain name on the account.

E-mail sent to the address “sample-test@example.com” will look for these e-mail rule files, in this order:

.qmail-example:com-sample-test
.qmail-example:com-sample-default
.qmail-example:com-default
.qmail-default

The actions found in the matching rule file will be used. More detail is given on specific actions below.
Qmail rewrites periods in e-mail addresses as colons. So, example.com in a qmail rule file becomes example:com.

The files listed above will be used in this way:

.qmail-example:com-sample-test
– will match only e-mail sent to the specific address sample-test@example.com
.qmail-example:com-sample-default
– will match “sample-ANYTHING@example.com,” so in this case it would be used
– will NOT match “sample@example.com”
.qmail-example:com-default
– will match e-mail to any address @example.com that has not already matched anything
.qmail-default
– used for general e-mail to any domain name in your account.
When e-mail comes in, the system checks it against the qmail rules. No matter which directory contains the rules, the most specific qmail rule “wins.” Using joe@example.com as an example, the qmail rules are examined in this order:

.qmail-example:com-joe
.qmail-example:com-default
.qmail-default
If both /var/rules/USERNAME and /usr/home/USERNAME have the exact same file, the one in /var/rules/ will be followed.
Once an “exit” condition has been found within a rule file, parsing stops.

Mail Actions within a qmail Rule

The major categories of actions that can be triggered within a recipe are:

Forward – send the e-mail to another e-mail address
File – save the e-mail to a file on your server
Pipe To Script — pass the e-mail to an external script (this is how the autoresponder in the Account Control Center works)
Qmail rules are plain text files with one action per line. Multiple actions will be parsed until an exit condition is encountered or until the end of the file is reached. The leading character on each line normally determines what happens with the e-mail.

& – Forwards the mail.
/ – Files the mail.
| – Pipes the mail to a script.
Examples

To forward e-mail for sample@example.com to myself@myisp.com, create a file called .qmail-example:com-sample. It would have these contents:

&myself@myisp.com

To save out e-mail for sample@example.com to your incoming e-mail spool, .qmail-example:com-sample would contain:

/var/mail/USERNAME

To save out e-mail for sample@example.com as well as forward it to myself@myisp.com, .qmail-example:com-sample would contain:

/var/mail/USERNAME
&myself@myisp.com

To bounce e-mail for badaddress@example.com back to the sender, .qmail-example:com-badaddress would contain:

|bouncesaying ‘Sorry, no mailbox here by that name.’

“bouncesaying” is a special program that comes with qmail. The message that comes after bouncesaying is what the bounce message will say at the top.

To keep a copy of e-mail to badaddress@example.com under the home directory, while bouncing it back to the sender, .qmail-example:com-badaddress would contain:

/usr/home/USERNAME/badaddress
|bouncesaying ‘Sorry, no mailbox here by that name.’

Note that bouncesaying is considered an exit condition, so it must appear last in the file (or else the mail will not be saved).

Most any combination of applicable forwards, filing, and piping to programs can be used. We recommend testing custom qmail configurations on unused e-mail addresses in your account first, so that no important e-mails are accidentally lost.

« Newer PostsOlder Posts »

Powered by WordPress