Pages

Monday, October 24, 2011

Example syntax for Secure Copy (scp)

What is Secure Copy?

scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

Examples

Copy the file "foobar.txt" from a remote host to the local host

    $ scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file "foobar.txt" from the local host to a remote host

    $ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy the directory "foo" from the local host to a remote host's directory "bar"

    $ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"

    $ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
    your_username@rh2.edu:/some/remote/directory/

Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host

    $ scp foo.txt bar.txt your_username@remotehost.edu:~

Copy the file "foobar.txt" from the local host to a remote host using port 2264

    $ scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

    $ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .
    $ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\} .

scp Performance

By default scp uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.
    $ scp -c blowfish some_file your_username@remotehost.edu:~
It is often suggested that the -C option for compression should also be used to increase speed. The effect of compression, however, will only significantly increase speed if your connection is very slow. Otherwise it may just be adding extra burden to the CPU. An example of using blowfish and compression:


    $ scp -c blowfish -C local_file your_username@remotehost.edu:~

SSH with private key authentication

How to Add ssh user on linux server ?


You can use the putyykey generator and generate the ssh key for the user and copy into the local computer.You can download the puttykey generator from the

URL: http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe

The following are the steps for creating ssh user with the authentication :-

#adduser test

#passwd test

#cd /home/test

#mkdir .ssh

#cd .ssh

#vi authorized_keys
In which file paste the generated key and save
Then add this user into wheel group

#vi /etc/group
Wheel:root,test

# vi /etc/sudoers
search the below line and remove comment.
===============================
# Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
===============================


Tat's it.....

File path in PLESK

These are the some of the paths in PLESK server

1) Site Document root

/var/www/vhosts/domain.com

2) Apache config File

/var/www/vhosts/domain.com/conf

3) Apache include files directory

/etc/httpd/conf.d
4) DNS/Named path
/var/named/run-root/var

5) Statistics path

/var/www/vhosts/domain.com /statistics

6) Path for qmail

/var/qmail/mailnames

7) Php.ini Path

/etc/php.ini or /usr/local/psa/admin/conf/php.ini

8) Maillog path

/usr/local/psa/var/log/maillog

9) Error log Path

/home/httpd/vhosts/domain.com/statistics/logs/error_log

10) Domain Access logs

/home/httpd/vhosts/domainname.tld/statistics/logs/access_log

11) Domain backup path

/var/lib/psa/dumps/domains
12) Mysql Path
/var/lib/mysql/database_name

Friday, October 21, 2011

How to Enable Passwordless Authentication with SSH


        Often times you have automated scripts that require access to multiple machines from a single source and need to do so without having to deal with ssh password prompts. And in other instances you may have a bastian host (strong point) security model which you would like to have passwordless communication from. Below are 10 steps to setting up passwordless authentication with SSH in Linux.

Step 1:(*note server1 is the source server and server2 will be the destination server)
server1# mkdir ~/.ssh
Step 2:
server1# cd ~/.ssh
Step 3:
server1# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (“your_local_home”/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
18:6a:e3:78:ab:2d:0c:8e:f9:67:f7:30:32:44:77:34 phil@server1
Step 4:
server1# scp ~/.ssh/id_rsa.pub phil@server2.philchen.com:/home/phil/id_rsa.server1.pub
Step 5:
server1# ssh phil@server2.philchen.com
Password:
Step 6:
server2# mkdir .ssh
Step 7:
server2# chmod 700 .ssh
Step 8:
server2# cat id_rsa.server1.pub >> .ssh/authorized_keys
Step 9:
server2# chmod 644 .ssh/authorized_keys
Step 10:
server2# exit
server1# ssh phil@server2.philchen.com
*Note repeat steps 4-10 for all target servers you would like passwordless access from server1
* FYI Ensure your /home/user directory has the permission 755 also!
You should be all set!

Difference between!!!!


1) SMTP and POP3:

SMTP Protocol:
The SMTP (Simple Mail Transfer Protocol) protocol is used by the Mail Transfer Agent (MTA) to deliver your eMail to the recipient's mail server. The SMTP protocol can only be used to send emails, not to receive them. Depending on your network / ISP settings, you may only be able to use the SMTP protocol under certain conditions.

The POP3 (Post Office Protocol 3) protocol provides a simple, standardized way for users to access mailboxes and download messages to their computers.When using the POP protocol all your eMail messages will be downloaded from the mail server to your local computer. You can choose to leave copies of your eMails on the server as well. The advantage is that once your messages are downloaded you can cut the internet connection and read your eMail at your leisure without incuring further communication costs. On the other hand you might have transferred a lot of message (including spam or viruses) in which you are not at all interested at this point.

2) IMAP vs.POP
The basic difference between IMAP and POP3 is that with POP3 you work most of the time offline because you only connect to the server to download new mail to your computer. This means you have to check your server mailbox periodically. Access from multiple computers/clients is possible by leaving your new mail on the server, but problematic. IMAP, on the other hand, allows you to always work with your mail live on the server. This means that a connection is made and typically maintained through your entire email session.

3) What is IMAP?

IMAP stands for Internet Message Access Protocol. It, like POP, is a way of accessing your email on servers. The primary advantage to IMAP is that since it maintains the original emails on the server, no matter how many different machines you login from you will have complete access to all your email. It also let’s you work with an unlimited number of server-side folders, which makes IMAP a perfect companion to server-side email filtering and Spam administration (see Procmail and Spamassassin).

Friday, October 14, 2011

Virtuozzo Command Line Utilities

The table below contains the full list of Virtuozzo command-line utilities.
General utilities are intended for performing day-to-day maintenance tasks:
vzctl
Utility to control Containers.
vzlist
Utility to view a list of Containers existing on the Node with additional information.
vzquota
Utility to control Virtuozzo Containers disk quotas.
Licensing utilities allow you to install a new license, view the license state, generate a license request for a new license:
vzlicview
Utility to display the Virtuozzo license status and parameters.
vzlicload
Utility to manage Virtuozzo licenses on the Hardware Node.
vzlicupdate
Utility to activate the Virtuozzo Containers installation, update the Virtuozzo licenses installed on the Hardware Node, or transfer the Virtuozzo license from the Source Node to the Destination Node.
Container migration tools allow to migrate Containers between Hardware Nodes or within one Hardware Node:

vzmigrate
Utility for migrating Containers from one Hardware Node to another.
vzmlocal
Utility for the local cloning or moving of the Containers.
vzp2v
Utility to migrate a physical server to a Container on the Node.
vzv2p
Utility to migrate a Container to a physical server.
Container backup utilities allow to back up and restore the Container private areas, configuration files, action scripts, and quota information:

vzbackup
Utility to back up Containers.
vzrestore
Utility to restore backed up Containers.
vzabackup
Utility to back up Hardware Nodes and their Containers. As distinct from vzbackup, this utility requires the Parallels Agent software for its functioning.
vzarestore
Utility to restore backed up Hardware Nodes and Containers. As distinct from vzrestore, this utility requires the Parallels Agent software for its functioning.
Template management tools allow the template creation, maintenance and installation of applications into a Container:

vzpkg
Utility to manage OS and application EZ templates either inside your Containers or on the Hardware Node itself.
vzmktmpl
Utility to create OS and application EZ templates.
vzveconvert
Utility to convert Containers based on Virtuozzo standard templates to EZ template-based Containers.
vzpkgproxy
Utility to create caching proxy servers for handling OS and application EZ templates.
vzrhnproxy
Utility to create RHN proxy servers for handling the packages included in the RHEL 4 and RHEL 5 OS EZ templates.
vzpkgls
Utility to get a list of templates available on the Hardware Node and in Containers.
vzpkginfo
Utility to get the information on any template installed on the Hardware Node.
vzpkgcreat
Create a new package set from binary RPM or DEB files.
vzpkgadd
Utility to add a new template to a Container.
vzpkglink
Utility to replace real files inside a Container with symlinks to these very files on the Node.
vzpkgrm
Utility to remove a template from a Container.
vzpkgcache
Update a set of preinstalled Container archives after new template installation.
Supplementary tools perform a number of miscellaneous tasks in the Hardware Node and Container context:
vzup2date
Utility to update your Virtuozzo software and templates.
vzup2date-mirror
Utility to create local mirrors of the Virtuozzo official repository.
vzfsutil
Utility for the VZFS optimization and consistency checking.
vzcache
Utility to gain extra disk space by caching the files identical in different Containers.
vzsveinstall
Utility to create the Service Container on the Hardware Node.
vzsveupgrade
Utility to update the packages inside the Service Container.
vzps and vztop
Utilities working as the standard ps and top utilities, with Container-related functionality added.
vzsetxinetd
Utility to switch some services between a standalone and xinetd-dependent modes.
vzdqcheck
Print file space current usage from quota's point of view.
vzdqdump and vzdqload
Utilities to dump the Container user/group quota limits and grace times from the kernel or the quota file or for loading them to a quota file.
vznetstat
Utility that prints network traffic usage statistic by Containers.
vzcpucheck
Utility for checking CPU utilization by Containers.
vzmemcheck
Utility for checking the Hardware Node and Container current memory parameters.
vzcalc
Utility to calculate resource usage by a Container.
vzcheckovr
Utility to check the current system overcommitment and safety of the total resource control settings.
vzstat
Utility to monitor the Hardware Node and Container resources consumption in real time.
vzpid
Utility that prints Container id the process belongs to.
vzsplit
Utility to generate Container configuration file sample, "splitting" the Hardware Node into equal parts.
vzcfgscale
Utility to scale the Container configuration.
vzcfgvalidate
Utility to validate Container configuration file correctness.
vzcfgconvert
Utility to convert Virtuozzo 2.0.2 Container configuration files to Virtuozzo 2.5.x format.
vzstatrep
Utility to analyze the logs collected by vzlmond and to generate statistics reports on the basis of these logs (in the text and graphical form).
vzreport
Utility to draw up a problem report and to automatically send it to the Parallels support team.
vzhwcalc
Utility to scan the main resources on any Linux server and create a file where this information will be specified.
vzveconvert
Utility to convert the Containers based on Virtuozzo standard OS templates to the EZ template-based ones.
vznetcfg
Utility to manage network devices on the Hardware Node.
vzmtemplate
Utility to migrate the installed OS and application templates from the one Hardware Node to another.

Wednesday, October 12, 2011

CentOS (RHEL) 4.4 FTP Install GUI Mode


How to install CentOS 4.4 (Red Hat Enterprise Linux) from an FTP server in GUI mode. This is knowledge which is needed for the RHCE Exam. The only prerequisite is that you have a server with and ftp server already running or the ability to install/start the/a ftp server.
  1. If you are not currently running ftp on your server, you will need to setup the daemon. Here is the steps for a CentOS 4.4 server with no firewall configured and SELinux disabled:
    [root@localhost ~]# yum install vsftpd
     *** ouput removed as its of no interest ***
    [root@localhost ~]# chkconfig --level 35 vsftpd on
    [root@localhost ~]# /etc/init.d/vsftpd start
    Starting vsftpd for vsftpd:                                [  OK  ]
  2. Create a directory on your ftp server in /var/ftp/pub (once again CentOS only). Mine is /var/ftp/pub/centos4.4.
    I will call this directory $CENTOS_FTP_ROOT.
    [root@localhost ~]# mkdir /var/ftp/pub/centos4.4
    [root@localhost ~]# cd /var/ftp/pub/centos4.4
  3. Download the CentOS ISO files. You can download the DVD image or regular ISOs.
  4. Extract all the ISOs or DVD into the $CENTOS_FTP_ROOT directory. You can do this by mounting the ISO directly and then copying the contents to $CENTOS_FTP_ROOT. This link is a good description on how to mount an iso.
    [root@localhost centos4.4]# pwd
    /var/ftp/pub/centos4.4
    [root@localhost centos4.4]# ls -al
    total 744
    drwxr-xr-x  8 root root   4096 Feb  5 22:32 .
    drwxr-xr-x  3 root root   4096 Feb  5 22:13 ..
    drwxr-xr-x  4 root root   4096 Feb  5 22:25 CentOS
    -rw-r--r--  1 root root   8859 Mar 18  2005 centosdocs-man.css
    -rw-r--r--  1 root root     78 Aug 23 15:29 .discinfo
    -rw-r--r--  1 root root  18009 Feb 28  2005 GPL
    drwxr-xr-x  2 root root  90112 Feb  5 22:25 headers
    drwxr-xr-x  3 root root   4096 Feb  5 22:25 images
    drwxr-xr-x  2 root root   4096 Feb  5 22:25 isolinux
    drwxr-xr-x  2 root root   4096 Feb  5 22:25 NOTES
    -rw-r--r--  1 root root   5781 Aug 23 14:37 RELEASE-NOTES-en
    -rw-r--r--  1 root root   7014 Aug 23 14:49 RELEASE-NOTES-en.html
    drwxr-xr-x  2 root root   4096 Feb  5 22:25 repodata
    -rw-r--r--  1 root root   1795 Feb 28  2005 RPM-GPG-KEY
    -rw-r--r--  1 root root   1795 Feb 28  2005 RPM-GPG-KEY-centos4
    -rw-r--r--  1 root root 569869 Aug 12 10:38 yumgroups.xml
  5. Now that you have ftp server setup, test it:
    [root@localhost ~]# ftp localhost
    Connected to localhost.localdomain.
    220 (vsFTPd 2.0.1)
    530 Please login with USER and PASS.
    530 Please login with USER and PASS.
    KERBEROS_V4 rejected as an authentication type
    Name (localhost:root): anonymous
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> cd /pub/centos4.4
    250 Directory successfully changed.
    ftp> dir
    227 Entering Passive Mode (127,0,0,1,172,204)
    150 Here comes the directory listing.
    drwxr-xr-x    4 0        0            4096 Feb 06 04:25 CentOS
    -rw-r--r--    1 0        0           18009 Mar 01  2005 GPL
    drwxr-xr-x    2 0        0            4096 Feb 06 04:25 NOTES
    -rw-r--r--    1 0        0            5781 Aug 23 19:37 RELEASE-NOTES-en
    -rw-r--r--    1 0        0            7014 Aug 23 19:49 RELEASE-NOTES-en.html
    -rw-r--r--    1 0        0            1795 Mar 01  2005 RPM-GPG-KEY
    -rw-r--r--    1 0        0            1795 Mar 01  2005 RPM-GPG-KEY-centos4
    -rw-r--r--    1 0        0            8859 Mar 18  2005 centosdocs-man.css
    drwxr-xr-x    2 0        0           90112 Feb 06 04:25 headers
    drwxr-xr-x    3 0        0            4096 Feb 06 04:25 images
    drwxr-xr-x    2 0        0            4096 Feb 06 04:25 isolinux
    drwxr-xr-x    2 0        0            4096 Feb 06 04:25 repodata
    -rw-r--r--    1 0        0          569869 Aug 12 15:38 yumgroups.xml
    226 Directory send OK.
    ftp>
  6. Create an CD from the boot.iso in $CENTOS_FTP_ROOT/images/. Or download it here
  7. Boot the CD.
  8. Press enter at the prompt:Press enter to install
  9. Select your language:Select your language
  10. Select your keyboard type:Select your keyboard type
  11. Choose FTP as your install method:Choose FTP as your install method
  12. Configure your network, I use DHCP:Configure your network, I use DHCP
  13. Put in the ip address or hostname of your ftp server on which you created $CENTOS_FTP_ROOT.
    Then put the path on the webserver to $CENTOS_FTP_ROOT. Mine is /var/ftp/pub/centos4.4.Put in the ip address or hostname of your ftp server
  14. Press Next:Press Next
  15. Select which type of system you would like to install:Select which type of system you would like to install
  16. I am selecting auto partition:I am selecting auto partition
  17. Press Next:Press Next
  18. Press Next:Press Next
  19. Press Next:Press Next
  20. Configure the network as you wish. I set my hostname:Configure the network as you wish
  21. Enable a firewall and SELinux or not, I did:Enable a firewall or not, I did
  22. Select your language:Select your language
  23. Choose your timezone:Choose your timezone
  24. Set your root password:Set your root password
  25. Change the package configuration if you wish:Change the package configuration if you wish
  26. Press Next:Press Next
  27. Screenshot of the install:Screenshot of the install
  28. Screenshot of post install configuration:Screenshot of post install configuration
  29. Press Reboot:Press Reboot
  30. Congratulations! Your OS has started:Congratulations! Your OS has started

CentOS (RHEL) 4.4 NFS Install Text Mode


How to install CentOS 4.4 (Red Hat Enterprise Linux) from an NFS server in TEXT mode. This is knowledge which is needed for the RHCE Exam. The only prerequisite is that you have a server with nfs already running or the ability to start the nfs server.
  1. If you are not currently running nfs on your server, you will need to setup the service. Here is the steps for a CentOS 4.4 server with no firewall configured and SELinux disabled:

    [root@localhost ~]# chkconfig --level 35 nfs on
    [root@localhost ~]# /etc/init.d/nfs start
    Starting NFS services: [ OK ]
    Starting NFS quotas: [ OK ]
    Starting NFS daemon: [ OK ]
    Starting NFS mountd: [ OK ]
  2. Create a directory on your nfs server. Mine is /tools/centos4.4. I will call this directory $CENTOS_NFS_ROOT.

    [root@localhost ~]# mkdir -p /tools/centos4.4
    [root@localhost ~]# cd /tools/centos4.4
  3. Export the $CENTOS_NFS_ROOT directory. The steps for CentOS 4.4:

    [root@localhost centos4.4]# nano -w /etc/exports
    [root@localhost centos4.4]# cat /etc/exports
    /tools/centos4.4 *(ro,insecure,all_squash)
    [root@localhost centos4.4]# exportfs -a
    [root@localhost centos4.4]# showmount -e localhost
    Export list for localhost:
    /tools/centos4.4 *
  4. Download the CentOS ISO files. You can download the DVD image or regular ISOs.
  5. Extract all the ISOs or DVD into the $CENTOS_NFS_ROOT directory. You can do this by mounting the ISO directly and then copying the contents to $CENTOS_NFS_ROOT. This link is a good description on how to mount an iso.

    [root@localhost centos4.4]# pwd
    /tools/centos4.4
    [root@localhost centos4.4]# ls -al
    total 744
    drwxr-xr-x 8 root root 4096 Feb 5 22:32 .
    drwxr-xr-x 3 root root 4096 Feb 5 22:13 ..
    drwxr-xr-x 4 root root 4096 Feb 5 22:25 CentOS
    -rw-r--r-- 1 root root 8859 Mar 18 2005 centosdocs-man.css
    -rw-r--r-- 1 root root 78 Aug 23 15:29 .discinfo
    -rw-r--r-- 1 root root 18009 Feb 28 2005 GPL
    drwxr-xr-x 2 root root 90112 Feb 5 22:25 headers
    drwxr-xr-x 3 root root 4096 Feb 5 22:25 images
    drwxr-xr-x 2 root root 4096 Feb 5 22:25 isolinux
    drwxr-xr-x 2 root root 4096 Feb 5 22:25 NOTES
    -rw-r--r-- 1 root root 5781 Aug 23 14:37 RELEASE-NOTES-en
    -rw-r--r-- 1 root root 7014 Aug 23 14:49 RELEASE-NOTES-en.html
    drwxr-xr-x 2 root root 4096 Feb 5 22:25 repodata
    -rw-r--r-- 1 root root 1795 Feb 28 2005 RPM-GPG-KEY
    -rw-r--r-- 1 root root 1795 Feb 28 2005 RPM-GPG-KEY-centos4
    -rw-r--r-- 1 root root 569869 Aug 12 10:38 yumgroups.xml
  6. Create an CD from the boot.iso in $CENTOS_NFS_ROOT/images/. Or download it here
  7. Boot the CD.
  8. Press enter at the prompt:Press enter to install
  9. Select your language:Select your language
  10. Select your keyboard type:Select your keyboard type
  11. Choose NFS image as your install method:Choose NFS image as your install method
  12. Configure your network, I use DHCP:Configure your network, I use DHCP
  13. Put in the ip address or hostname of your nfs server on which you created $CENTOS_NFS_ROOT. Then put the path on the webserver to $CENTOS_NFS_ROOT. Mine is /tools/centos4.4.Put in the ip address or hostname of your nfs server
  14. Select OK:Select OK
  15. Select which type of system you would like to install:Select which type of system you would like to install
  16. I am selecting auto partition:I am selecting auto partition
  17. Crap, its going to delete all my data! Select Yes:Its going to delete all my data! Select Yes.
  18. Select OK:Select OK
  19. Select YES:Select YES
  20. Select OK:Select OK
  21. Select OK:Select OK
  22. Select OK:Select OK
  23. Select OK:Select OK
  24. Select OK:Select OK
  25. Select OK:Select OK
  26. Configure the network as you wish:Configure the network as you wish
  27. Set your hostname:Set your hostname
  28. Enable a firewall or not, I did:Enable a firewall or not, I did
  29. Enable SELinux or not, I did:Enable SELinux or not, I did
  30. Select your language:Select your language
  31. Choose your timezone:Choose your timezone
  32. Set your root password:Set your root password
  33. Change the package configuration if you wish:Change the package configuration if you wish
  34. Select OK:Select OK
  35. Screenshot of the install:Screenshot of the install
  36. Screenshot of post install configuration:Screenshot of post install configuration
  37. Press Reboot:Press Reboot
  38. Congratulations! Your OS has started:Congratulations! Your OS has started