skip to main |
skip to sidebar
This article just illustrates the use of the expect command used for automatic logging to a remote machinewithout using the complex ssh key pair exchange and all...!Make sure you have the expect package installed in your machine...lets try for telnet login...make a file by name telnetme$vi telnetme#!/usr/bin/expecteval spawn telnet 10.0.0.27set timeout 30expect login:send "username\r"expect password:send "password\r"interactNow set execute permission to the script and copy it to any of the directories in your PATH variableFor SSH Login theres a little change...I am here making a file by nane sshme$vi sshme#!/usr/bin/expecteval spawn ssh 10.0.0.27set timeout 30expect password:send "password\r"interactNOTE: change the italicised strings with appropriate username and passwordIt is recommended that you give read permission only to the user who is using this script , otherwise all users could read the plain password enteredPS: Please extend the features of expect if someone knows it...
Hollaaaaaaaa....
Yesterday i was trying to make a DVD out of my 5 RHEL 5.0 CDs. During the process i ended up losing my two plain DVD's.
But the most interesting thing is that i finally found the solution :). And i thought i must publish it cause i dont want
any other person to have the same difficulties i encountered.
alrights, lets get started...
I am creating a directory to copy all the RHEL 5.0 CDs
#mkdir /tmp/RHEL5_DVD
Loop mount the individual ISO images to any directory
#mount -o loop /path/to/iso1.iso /mnt
then copy the first CD contents to /tmp/RHEL5_DVD
#cd /mnt
#cp -r * /tmp/RHEL5_DVD
make sure you copied the .discinfo file also
#cp .discinfo /tmp/RHEL5_DVD
now unmount /mnt and mount the second iso.
#mount -o loop /path/to/iso2.iso /mnt
then copy all the rpm files inside /mnt/Server to /tmp/RHEL5_DVD/Server
#cp /mnt/Server/*.rpm /tmp/RHEL5_DVD/Server
we need to append the contents of the TRANS.TBL file found inside /mnt/Server to that inside /tmp/RHEL5_DVD/Server
#cat /mnt/Server/TRANS.TBL >> /tmp/RHEL5_DVD/Server/TRANS.TBL
NOTE:We are going to make a single TRANS.TBL file with all the TRANS.TBL files inside every isos.
Do the same thing for third, fourth and fifth iso files.
while copying the fifth iso file's contents, you should copy the rpm files under /mnt/VT/ to /tmp/RHEL5_DVD/VT
and append the TRANS.TBL file found under /mnt/Server/VT to /tmp/RHEL5_DVD/VT/TRANS.TBL
Now edit the .discinfo file inside the directory /tmp/RHEL5_DVD
to change the fourth line from 1 to 1,2,3,4,5
NOTE: If you miss any cd number, then installation would prompt you to insert that cd.
So you must include all the cd numbers correctly!
Now we must create the ISO image of the /tmp/RHEL5_DVD directory.
Free some 3 GB space in your HDD as the entire build would make an iso file of size
no less than 2.6 GB.
#cd /tmp/RHEL5_DVD
I assume you are creating the iso image inside /DVD directory.
#mkisofs -o /DVD/rhel5dvd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat
-no-emul-boot -boot-load-size 4 -boot-info-table -J -r .
NOTE the . at the end of the previous command which specifies the current directory.
the -b flag to mkisofs command specifies the path and filename of the boot
image to be used when making the bootable iso.
the -c flag specifies the path and filename of the boot
catalog.
Now to burn the DVD, use the growisofs command.
#growisofs -dvd-compat -Z /dev/dvdwriter-hdc=/DVD/rhel5dvd.iso
NOTE: dd (disk duplicator) command can also be used to burn the iso image.
#dd if=/DVD/rhel5dvd.iso of=/dev/dvdwriter-hdc obs=32k seek=0
(plain DVDs and DVD burners are not that cheap here in my locality.. :D)
consult the man page of dd for more information.
make changes to the DVD device. I have plugged the DVD as secondary master in
my desktop PC.
the = sign used in the growisofs command finalized the DVD disc.
linuxly yours....
~mj0vy
The need to encrypt filesystems is to make ur data more secure and safe.The whole steps include1) Creating a partition with the fdisk utility ( pre-requisite :-( )2) Selecting a cipher.3) Setting up a loop device using the losetup command.4)
Detaching the loop back device
5) Mouting the parition
alright... lets get started..!let me assume u have created the partition /dev/hda7first of all we need to shred the partition#shred -n 1 /dev/hda7this command would overwrite /dev/hda7 only once! -OR-we can use the dd command to overwrite the device..#dd if=/dev/urandom of=/dev/hda7 bs=1MNow we need to select a cipher for the encyptionu can list the available ciphers by cat /proc/cryptohere i am using the serpent ciphermake sure u have got the serpent cipher modules inbuilt in ur kernel!otherwise try#modprobe serpent#modprobe cryptoloop ( to setup the loop device described in the next step )the next step is to setup a loop device using the losetup command.#losetup -e serpent /dev/loop0 /dev/hda7It prompts u for a passphrase. DONOT forget the passphrase as its not easy to changethe passphrase as it is hashed to create the encryption key.Now create a filesystem on the loopback device and mount it.#mke2fs -j /dev/loop0#mkdir /cryptfs#mount -t ext3 /dev/loop0 /cryptfsonce we have mounted the partition, we can then detach theloop back device frm the partition.#umount /cryptfs#losetup -d /dev/loop0Now mount the partition,#mount -o encryption=serpent /dev/hda7 /cryptfsthe passphrase which we have given during the loop device setup will be askedand u need to enter it correctly to mount the device.
SAMBA:------Samba acts as a fileserver for windows/linux using the SMB protocol(Server Message Block), SMB is sometimes referred to as CIFS (Common InternetFile System).Server Side:------------The directory to be shared from a linux server has to be given a sharename.Clients access server's directory by referring to this sharename.We can have user level access list and host level access list in samba.Those users to whom server is granting access shuld be a unix server useras well, and those users shuld be converted to samba users by giving them aseperate samba password also. The samba users password database is locatedinside /etc/samba directory in the name smbpasswd.ie, /etc/samba/smbpasswdEg:There is a directory in the server named /backups.These directory needs to be shared to clients which use windows OS.First of all we need to give /backups a sharename, by which the windows clientsaccess our /backups. Let it be UNIXBAKUP.We are planning to give access to this share only for windows clients192.168.0.3 and 192.168.0.2 only.More over, they shuld be granted access if and only if they login as usersjack or jane.Open the samba configuration file using an editor,-------------------------------------#vi /etc/samba/smb.conf[UNIXBAKUP] comment = Share for windows clients path = /backups valid users = jane jack hosts allow = 192.168.0.3 192.168.0.2 writeable = yes create mask = 0765-------------------------------------Now we need to add the allowed users#useradd jane#useradd jack#passwd -l jack ; passwd -l janethis is done to lock their unix passwordNow we need to convert these unix users to samba users.#smbpasswd -a janenow u will be prompted for a password.this step only adds the user to the samba password database.we need to allow this user to use our samba server.#smbpasswd -e janesame way add the user jack also.now we need to give permission to users jane and jack the write permission inour share#chmod 777 /backups#/etc/init.d/smb start#chkconfig smb onto make our samba server persistent across reboots.now we can test whether our samba configuration is correct or not with thecommand testparm#testparmif any errors are there it will be reported.--------------------------------------------Client Side: (in 192.168.0.2 and 192.168.0.3)------------#smbclient //sambaserveraddress/sharename -U usernamehere#smbclient //192.168.0.4/UNIXBAKUP -U jane/jackenter the passwordu will be put into a samba shellsmb: \>now u are inside 192.168.0.4's /backups directoryfrm here if u want to get some files, frm with in samba shell issuesmb: \>mget filenamefile is now copied frm samba server to the client directory frm where we logged into the samba server.instead if u want to put some files frm the folder where u logged into thesamba server, issuesmb: \>mput file-frm-the-clientsmb: \>lsyou will be listed with the file u have just copied frm client to thesamba server.
Using GUI:
------------
Take run in KDE/Gnome and try
smb://sambaserverip
then u will be prompted for the samba username and password!
In M$ Windows u can access the Linux samba share by taking Start>Run and issuing
\\sambaserverip
upon opening any directory u will be asked the samba username and password...!
LVM Creation:
-------------
Create a linux partition, make it a LVM by toggling the linux partitions id to
8e.
Convert it to a physical volume by issuing the command
#pvcreate devicename
Then, make the volume group in that physical volume,
#vgcreate vgname devicename
Then make logical volumes in the volume group,
#lvcreate -L sizeM -n lvname vgname
Make a linux filesystem in the logical volume,
#mkfs.ext3 /dev/vgname/lvname
This device is a softlink to the device /dev/mapper/vgname-lvname
Then mount that logical volume,
#mount /dev/vgname/lvname
LVM Resizing:
-------------
LVM format 2.0 is now implemented which supports online resizing of filesystems.
check the current size of the filesystem by 'df -h'
Extend the above created logical volume BY X MB,
#lvextend -L +XM /dev/vgname/lvname
we are doing it without unmounting the filesystem
Now to make the extension effective, issue
#resize2fs /dev/vgname/lvname
now recheck the filesystem size by 'df -h',
now the filesystem will be extended by X MB.
Now if u want to reduce the logical volume TO X MB,
u must first umount the device, online reducing of logical volumes cannot be done..!
#umount
then u need to scan the filesystem for integrity.
#e2fsck -f /dev/vgname/lvname
now resize the filesystem
#resize2fs /dev/vgname/lvname X MB
then reduce the volume with lvreduce and mount it..
#lvreduce -L XM /dev/vgname/lvname
#mount /dev/vgname/lvname
this is how we can convert the init based service ftp to an xinetd service..1) First of all we need to make FTP not to listen on port 21 by making 'listen=NO' in/etc/vsftpd/vsftpd.conf.2) Then, make a file named ftp inside /etc/xinetd.d the contents of /etc/xinetd.d/ftp should look like this service ftp { disable = no socket_type = stream wait = no user = root server = /usr/sbin/vsftpd server_args = /etc/vsftpd/vsftpd.conf nice = 10 flags = IPv4 }3) then restart the xinetd service by#/etc/init.d/xinetd restart#chkconfig xinetd onnow if u 'nmap localhost', u can see that the port 21 is now open...!
Services in Linux:------------------Services in linux are classified into TWO.XINETD and INIT based services.XINETD is itself an INIT based service.All INIT based services are invoked by the command,#/etc/init.d/service start
XINETD services' configuration file resides in /etc/xinetd.d directory.
All the services are made persistent across reboots by
#chkconfig servicename on , for all init based services.
#chkconfig xinetd on , for all xinetd based services.
XINETD services: e(X)tended (I)(N)tern(E)(T) services (D)aemon
--------------------------------------------------------------
xinetd service is called a super server as it serves as the daemon for a number of seperate services.
For all the services which use xinetd, we need to start the xinetd daemon only. xinetd services' configuration files can be found at /etc/xinetd.d/servicename
All the xinetd services are having the same syntax facilitating the administration of xinetd services very easy.
Extensive logging and fine grained access control can be implemented with xinetd
Xinetd service forks process ids only when a client requests the service.
Only one process is necessary to invoke process ids for individual xinetd services, ie the xinetd super daemon itself.
Logging based on hostname are not supported in XINETD
INIT based services:
--------------------
INIT based services are having individual configuration files under
/etc/service/servicename.
Their starting scripts are placed under /etc/init.d/servicename.
Each individual services can be started by
#/etc/init.d/servicename start
and to sum up... the more the processes .. the lesser the performance of the machine..
so it is advisable to have more xinetd based services than init based ones..!