Labels

Linux (46) network (13) troubleshoot (13) command (10) virtualization (10) ubuntu (9) Windows (8) cisco (7) security (7) router (6) Tools (5) software (5) vmware (5) ospf (3) eigrp (1) zimbra (1)

2010年3月25日

No Password login - SSH

Step 1: Create public and private keys using ssh-key-gen on local-host

jsmith@local-host$ [Note: You are on local-host here]

jsmith@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 
jsmith@local-host

Step 2: Copy the public key to remote-host using ssh-copy-id

jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
jsmith@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.

Step 3: Login to remote-host without entering the password

jsmith@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[Note: SSH did not ask for password.]

jsmith@remote-host$ [Note: You are on remote-host here]

ref.: http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/

2010年3月23日

Apache+SSL in Debian Quick Setup

Step1: apt-get install apache2 openssl

Step2: (Generate cert file)
mkdir /etc/apache2/ssl
 
  RANDFILE=/dev/random openssl req $@ -new -x509 -days 365 -nodes \
    -out /etc/apache2/ssl/apache.pem \
    -keyout /etc/apache2/ssl/apache.pem

  chmod 600 /etc/apache2/ssl/apache.pem

Step3: (Config for apache2)
  cd /etc/apache2/sites-available/
  cp default ssl

Step4: (Enable the site. This is done by making a sym-link to the configuration 
from /etc/apache2/sites-enabled/.)
  a2ensite ssl

Step5: (To enable the ssl module from /etc/apache2/mods-available)
  a2enmod ssl

Step6: (Add 443 port to /etc/apache2/ports.conf)
  Listen 443

Step7: (Edit /etc/apache2/sites-available/ssl)
  NameVirtualHost *:443
  
   SSLEngine On
   SSLCertificateFile /etc/apache2/ssl/apache.pem
 
Step8: Restart apache2  /etc/init.d/apache2 restart 

2010年3月15日

Simple logrotate - make your log file archieve

If you want to make your log files archieve, you can create file in /etc/logrotate.d, those files will be included in logrotate.conf
Here is the file sample:
/var/log/linuxserver/linux.log {
        rotate 7
        daily
        compress
        delaycompress
        missingok
        notifempty
        create 660 linuxuser linuxuser } 

This config file will run daily, create maximum 7 archives owned by linuxuser 
and linuxuser group with 660 permissions,compress all logs and exclude only yesterdays and empty log files.
Here are some selected logrotate configuration keywords.

daily Log files are rotated every day.
weekly Log files are rotated if the current weekday is less than the weekday of the last rotation or if more than a week has passed since the last rotation. This is normally the same as rotating logs on the first day of the week, but if logrotate is not being run every night a log rotation will happen at the first valid opportunity.
monthly Log files are rotated the first time logrotate is run in a month (this is normally on the first day of the month).
notifempty Do not rotate the log if it is empty (this overrides the ifempty option).
nocompress Old versions of log files are not compressed.
delaycompress Postpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with compress. It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time.
compress Old versions of log files are compressed with gzip by default.
mail address When a log is rotated out of existence, it is mailed to address. If no mail should be generated by a particular log, the nomail directive may be used.
missingok If the log file is missing, go on to the next one without issuing an error message.

To run the logrotate manually, issue the command:
logrotate -v /etc/logrotate.conf

2010年3月11日

Journaled quota

Journaled quota

(Assume installed quota package)
  • vi /etc/fstab
    • /dev/sda1 / ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0 1
  • touch /aquota.user /aquota.group
  • mount -o remount /
  • quotacheck -avug
  • quotaon -avug
  • edquota -u ray
  • edquota -g myquotagrp

2010年3月10日

RPM command example

Install
# rpm -ivh foo-2.0-4.i386.rpm
# rpm -i ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm
# rpm -i http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm

Erase
# rpm -e foo

Upgrade
# rpm -Uvh foo-1.0-2.i386.rpm
# rpm -Uvh ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm
# rpm -Uvh http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm

Query
# rpm -qa  <------To query all installed packages.
# rpm -q foo  <------To query a RPM package.
# rpm -qi foo  <------To display package information.
# rpm -ql foo  <------To list files in installed package
# rpm -qf /usr/bin/mysql  <------Which package owns a file?
mysql-3.23.52-3
# rpm -qpl kernel-2.4.20-18.10.1.i686.rpm
# rpm -qpl ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm
# rpm -qpl http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
List files in RPM file.

Verify
# rpm --verify mysql
To verify an installed package. The output is listed using the following codes that signify what failed:
S File size
  M Mode (includes permissions and file type)
  5 MD5 sum
  L Symlink 
  D Device 
  U User 
  G Group 
  T Mtime

Take for example the following:
# rpm --verify mysql
  S.5....T c /etc/my.cnf
This example indicates that file /etc/my.cnf failed on:
File size 
  MD5 Sum 
  Modified Time 
However, the "c" tells us this is a configuration file so that explains the changes. It should still be looked at to determine what the changes were.