Wednesday, September 10, 2014

How to Encrypt And Decrypt Files with GPG?

Linux: How To Encrypt And Decrypt Files With A Password in gpg?


T

o encrypt and decrypt files with a password,  you canuse gpg command. This is an encryption  tool for Linux/UNIX like operating system.

gnupg

GnuPG stands for GNU Privacy Guard.

Encrypting a file in linux

To encrypt a single file, 
$ gpg -c somefilename
It will prompt for password:
Enter passphrase:
Repeat passphrase:
This will create a somefilename.gpg file. Where,
  • -c : Encrypt with symmetric cipher using a passphrase. The default symmetric cipher used is CAST5, but may be chosen with the --cipher-algo option. This option may be combined with --sign (for a signed and symmetrically encrypted message), --encrypt (for a message that may be decrypted via a secret key or a passphrase), or --sign and --encrypt together (for a signed message that may be decrypted via a secret key or a passphrase).
Note that if you ever forgot your password (passphrase), you cannot recover the data as it use very strong encryption.

How to Decrypt a file

To decrypt file use the gpg command as follow:
$ gpg somefilename.gpg
gpg: CAST5 encrypted data
Enter passphrase:

Monday, September 8, 2014

How to check either string is present or not in TCL programming?



How to check either string is present or not in TCL programming?


Below is example to search xyz in long string let's say http://xyz.com/home/index.html
set variable_name http://xyz.com/home/index.html
if {![lsearch -regexp $variable_name xyz ]} {
puts " Not found"
exit 1
 } else {
puts "OK"
}

How to keep SSH session alive in PUTTY?



How to keep SSH session alive in putty utility?

Open putty-->goto Connection--> look for "Seconds between keepalives (write 30 seconds)

Enjoy !!!



Sunday, March 16, 2014

How to install and configure sendmail server in Linux?


The sendmail can be configured from  files in /etc/mail and a directory of configuration files in /usr/share/sendmail-cf. There are two basic configuration files:
  1. sendmail.cf The main sendmail configuration file.
  2. sendmail.mc A macro that's easier to edit, which can be used to generate a new sendmail.cf file.
In this example you can use two systems linux server , and linux clients.
  • A linux server with ip address 192.168.0.100 and hostname Server
  • A linux client with ip address 192.168.0.10 and hostname Client1
  • A Configured DNS server on Linux server and remember to set MX record
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall (iptable) should be off for port 25 on server


Configure sendmail server

sendmail and m4 rpm are required to configure sendmail server

 sendmail rpm

Sendmail program reads the /etc/mail/sendmail.cf. Change the /etc/mail/sendmail.mc file. When Sendmail is started or restarted with the service sendmail restart command a new sendmail.cf file is automatically generated if sendmail.mc has been modified.

open /etc/mail/sendmail.mc for editing
vi /etc/mail/sendmail.conf


The following line limits sendmail access to connect local host only [line no 116]
sendmail.mc

 You can allow other computers to use your sendmail server by commenting out this line.

In the sendmail.mc file , lines that begin with dnl, which stands for delete to new line, are considered comments. Some lines end with dnl, but lines ending in dnl are not comments

comment this line with dnl keyword followed by # sign
sendmail.mc
save this file with :ZZ and exit.

Now generate new sendmail.cf file by using m4 command as shown here
m4


Run chkconfig so that sendmail server should start automatically after restart the server and start the sendmail service

 service sendmail restart
 

Testing of your sendmail server


  Create user abc
useradd abc
Add password
passwd abc

echo "BODY" | mail -s "Subject" abc
mail sent to abc user.

How to find which process is eating RAM memory in Linux Operting System?

ps aux | awk '$6 > 0{print $3, $4, $5, $6}'
or

ps aux | awk '{print $2, $4, $11}' | sort -k2r | head -n 20