Monday, May 9, 2011

comparators in perl and shell

SHELL:

KSH

you can use == or = to compare string

bash: if you use "==" will lead to syntax errors so be cautious,we have to use only "=" in this case.

Another speciality about = operator is it can be used for both string and numbers.

and can use -eq  for only comparing numbers

And -eq if used for compring strings,it will return syntax error.

PERL

it is just the opposite what you  use in shell

eq can be used to compare only string

= can be used for only numbers

Though = may seem to work for strings it will always return true.So be Cautious.

Saturday, May 7, 2011

Connection refused(public key,password authentication,keyboard interactive)

This error comes when you are trying to login to a machine using ssh or telnet

This may be due to

1)the password you provide may be wrong

2)next chance may be the user account you are using to login to a remote machine can be locked.

for example:ssh karthik@123.45.66.77

this may throw this error
 In this case the karthik account in 123.45.66.77 can be locked.


This can be found out by checking /etc/shadow file in 123.45.66.77 .The karthik account in /etc/shadow file
can be mentioned with *LK* showing it is locked.

extracting .cpio file

syntax:

cat cpio_file | cpio -idmv
use this to extract .cpio file


This works fine.

configuring ssh in Ethernet Switch

Before configuring ssh module in Ethernet switch make sure that ssh modue is installed.

To check ssh module is installed :

show management

this command shows all the module installed in the Ethernet switch  :
if you find the ssh module not installed.Install it before configuring ssh.

After installing  exsshd module,do the following steps:

1)configure ssh2 keys
this is to generate the ssh2 keys

2)enable ssh2
this is to enable the ssh2 module in Ethernet switch.

3)show configuration exsshd 
This will show the configuration of ssh module installed in Ethernet switch.




Friday, May 6, 2011

For locking a account and unllocking

For Locking the account you can use

passwd -l {username}

For unlocking the account you can use

passwd -u {username}

Once the account is locked no person can login to the user via the locked account.

The change can be noticed in /etc/shadow's fie for the locked account.

The account can  be locked only by the superuser or any user with that  privelage.

For adding a role to a user account

You can use the command

usermod -R adminsecurity  anand

here anand is a user
and adminsecurity is the role added to the user anand

For adding the role to the user,you must be a super user(ROOT).





port 22 connection refused

if this errors while trying ssh
Check sshd daemon is running in the server machine

you can check this by logging into the server machine and trying

ps -ef | grep sshd


if you find the ssh daemon process you check port 22 is used by some other process 


netstat -tupn
or  
chkconfg --list sshd