Friday, July 31, 2015

Tail a file with current date

root@FR-121:/var/log/freeradius/radacct# cat detail
tail -f ./9.27.110.154/detail-$(date +"%Y%m%d") -f ./9.27.14.85/detail-$(date +"%Y%m%d") -f ./9.27.14.89/detail-$(date +"%Y%m%d") | grep -i -e "NAS-IP-Address" -e "Acct-Status-Type" -e "audit-session-id" -e "Acct-Session-Id" -e "Status" -e "Packets" -e "Terminate" -e "time"
root@FR-121:/var/log/freeradius/radacct#
root@FR-121:/var/log/freeradius/radacct#
root@FR-121:/var/log/freeradius/radacct# ./detail
        Acct-Session-Time = 493
        Acct-Terminate-Cause = Idle-Timeout
        Event-Timestamp = "Jul 31 2015 19:29:59 IST"
        Acct-Delay-Time = 0
        Timestamp = 1438330664
        Acct-Session-Time = 20
        Acct-Terminate-Cause = Session-Timeout
        Event-Timestamp = "Jul 31 2015 09:20:02 IST"
        Acct-Delay-Time = 0
        Timestamp = 1438342938
        Acct-Status-Type = Start
        Event-Timestamp = "Jul 31 2015 09:02:29 IST"
        Acct-Delay-Time = 0
        Timestamp = 1438342938
^Croot@FR-121:/var/log/freeradius/radacct#
root@FR-121:/var/log/freeradius/radacct#
root@FR-121:/var/log/freeradius/radacct#
root@FR-121:/var/log/freeradius/radacct# 

Friday, July 17, 2015

Tuesday, July 14, 2015

Generate a list of unique entries in an Excel column

http://www.techrepublic.com/blog/microsoft-office/generate-a-list-of-unique-entries-in-an-excel-column/


Use NetSetMan to connect to the desired wireless network

Use NetSetMan to connect to the desired wireless network from Win 7 VM
Below is the link:
http://www.netsetman.com/en/freeware

Wednesday, July 8, 2015

Configure passwordless ssh from linux to windows PC having cygwin installed

[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>ssh -l admin 10.104.99.166
admin@10.104.99.166's password:
Last login: Tue Jul  7 20:43:48 2015 from 10.64.69.73

admin@AAA-PC1 ~
$

admin@AAA-PC1 ~
$ exit
logout
Connection to 10.104.99.166 closed.
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/users/srikragh/.ssh/id_rsa):
/users/srikragh/.ssh/id_rsa already exists.
Overwrite (y/n)?
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/users/srikragh/.ssh/id_rsa):
/users/srikragh/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /users/srikragh/.ssh/id_rsa.
Your public key has been saved in /users/srikragh/.ssh/id_rsa.pub.
The key fingerprint is:
cf:2c:47:ea:3a:7a:8e:5e:a9:72:9d:03:12:a5:a8:80 srikragh@bear-bld-lnx
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>ssh admin@10.104.99.166 mkdir -p .ssh
admin@10.104.99.166's password:
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>cat .ssh/id_rsa.pub | ssh admin@10.104.99.166  'cat >> .ssh/authorized_keys'
admin@10.104.99.166's password:
Permission denied, please try again.
admin@10.104.99.166's password:
Permission denied, please try again.
admin@10.104.99.166's password:
cat: .ssh/id_rsa.pub: No such file or directory
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>
[bear-bld-lnx:/auto/tftp-blr-users1/srikragh]>cd
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>cat .ssh/id_rsa.pub | ssh admin@10.104.99.166  'cat >> .ssh/authorized_keys'
admin@10.104.99.166's password:
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>ssh admin@10.104.99.166 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>ssh admin@10.104.99.166
Last login: Wed Jul  8 13:12:16 2015 from 10.64.69.73

admin@AAA-PC1 ~
$

admin@AAA-PC1 ~
$ exit
logout
Connection to 10.104.99.166 closed.
[bear-bld-lnx:/users/srikragh]>
[bear-bld-lnx:/users/srikragh]>

Tuesday, July 7, 2015

Installing Cygwin in Windows 7

Please refer below link:

http://docs.oracle.com/cd/E24628_01/install.121/e22624/preinstall_req_cygwin_ssh.htm#EMBSC150


Thursday, July 2, 2015

Kill a process using port number

root@FR-121:~# psr
freerad   2744     1  0 Jul01 ?        00:00:00 /usr/sbin/freeradius -i 10.104.99.121 -p 1645
root      6151  4648  0 22:26 pts/4    00:00:00 grep --color=auto radius
root@FR-121:~#
root@FR-121:~#
root@FR-121:~#
root@FR-121:~#
root@FR-121:~# kill $(sudo lsof -t -i:1645)
root@FR-121:~#
root@FR-121:~#
root@FR-121:~# psr
root      6155  4648  0 22:26 pts/4    00:00:00 grep --color=auto radius
root@FR-121:~#
root@FR-121:~#

Source: http://stackoverflow.com/questions/9346211/how-to-kill-a-process-on-a-port-on-ubuntu

Wednesday, July 1, 2015

SSH and execute a set of commands

Steps followed to SSH and execute a set of commands:
1. Login to the power cycler using ssh
2. Issue power cycle command

Below is a working sample:

root@FR-121:~# cat cycle_katana
sshpass -p "cisco123" ssh -o StrictHostKeyChecking=no admin@10.105.108.26 << EOF
power outlets 7 cycle /y
EOF
root@FR-121:~#

Source: http://www.shellhacks.com/en/Running-Commands-on-a-Remote-Linux-Server-over-SSH

################################################################################

Execute a single command over ssh:

[ats-earms-lnx:/auto/tftp-blr-users1/srikragh]>ssh root@10.104.99.121 "sudo lsof -t -i:1645"
10493
[ats-earms-lnx:/auto/tftp-blr-users1/srikragh]>

Source: http://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/