Understanding ls command output

ls command provides information about a file.  In Linux everything is represented as a file. A sample output of ls -lh is give below.

ls command

Total: show total size of the folder.

File type: First field in the output is file type. If the there is a – it means it is a plain file. If there is d it means it is a directory, c represents a character device , b represents a block device.

Owner: This field provide info about the creator of the file.

Group: This filed provide info about who all can access the file.

File size: This field provide info about the file size. By default the ls -l command give output in bytes.

Other field are self explanatory.

Now permission can be divided into three parts: Owner, Group, Other

permissions

r: read permission
w: write permission
x: execute permission

Octal values are used to represent permissions.

4 -> read permission
2 -> write permission
1 -> execute permission

Example: If a file have 764 permission it means owner can do all operation on file, group can do read and write operation on file and other can read only the file

Posted in Linux | 1 Comment

Understanding ntpq output

 

In Ubuntu NTP configuration is kept under file /etc/ntp.conf

ntpq> peer
      remote       refid         st t  when poll  reach   delay  offset jitter
==============================================================================
 ntp.ubuntu.com   .POOL.         16 p   -    64    0     0.000   0.000   0.000
*123.108.200.124  210.23.25.77   2  u   83   128  375    241.212 -19.350 8.176
ntpq> associations

ind  assid status conf reach auth condition last_event cnt
===========================================================
 1   7770  8811   yes  none  none reject     mobilize 1

refid – Where or what the remote peer or server is itself synchronised to.

stratum: the devices which are considered independent time sources are classified as stratum 0 sources; the servers directly connected to stratum 0 devices are classified as stratum 1 sources; servers connected to stratum 1 sources are then classified as stratum 2 sources and so on

t – Type (u: unicast or manycast client, b: broadcast or multicast client, l: local reference clock, s: symmetric peer, A: manycast server, B: broadcast server, M: multicast server

when: number of seconds passed since last response.

poll: poll interval. NTP Client sends NTP packets at intervals ranging from 8 s to 36 hr

reach: The reach peer variable is an 8-bit shift register displayed in octal format. When a valid packet is received, the rightmost bit is lit. When a packet is sent, the register is shifted left one bit with 0 replacing the rightmost bit. If the reach value is nonzero, the server is reachable; otherwise, it is unreachable.

delay: The round-trip delay to peer is reported in milliseconds.

offset: Offset is the time difference between the peers or between the server and client.

In the output of peer command you can see there are few characters the meaning of those characters is as follows:

* Synchronized to this peer
# Almost synchronized to this peer
+ Peer selected for possible synchronization
– Peer is a candidate for selection
~ Peer is statically configured

Posted in Linux | Leave a comment

Cisco Firepower Management console HA configuration.

In this post we will configure HA for Cisco firepower management console. We have two virtual FMC on 6.7.0 (build 65)

Step 1> Ensure VDB, Rule updates, Geolocation updates are matching on both FMC. Navigate to System > updates tab

Step 2> Login to the web ui of FMC which is going to be secondary, Navigate to System > Integration > High Availability, Select secondary, put the ip address of primary FMC, enter a registration key this key needs to be kept on primary node as well, click register

Step 3> Login to the web ui of FMC which is going to be primary, Navigate to System > Integration > High Availability, Select primary, put the ip address of secondary FMC, enter registration key which was kept on secondary while registering, click register

Posted in CISCO, Cisco Firepower | Leave a comment

Hash of a file in windows without any additional utility

Step 1> Open power shell

Step 2> Run below command:

certutil -hashfile (Path_to_file) [HashAlgo]

Available HashAlgo are MD4, MD5, SHA1, SHA256, SHA512. Default is SHA1

example:
certutil -hashfile .\kali-linux-2021.1-live-amd64.iso SHA256
Posted in Powershell, Windows | Tagged , , , , , | 1 Comment

Paramiko to SSH into CISCO device:

import paramiko
import time

def show_version(remote_conn):
print "show_vesrion"
time.sleep(2)
remote_conn.send("\n")
remote_conn.send("\n")
remote_conn.send("show version\n")
time.sleep(2)

def my_ssh(ip,o):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port=22, username=user, password=pwd, look_for_keys=False, allow_agent=False)
remote_conn = ssh.invoke_shell() #Invoke the shell for interactive terminal
time.sleep(5)
#output = remote_conn.recv(65535)
#print output
remote_conn.send("\n")
remote_conn.send("\n")
remote_conn.send("\n")
remote_conn.send("\n")
print type(ip)
print type(o)
print "printing o"+o
print "printing ip"+ip
disable_paging(remote_conn)
output = remote_conn.recv(65535)

if "1" in o:
print "1 in my ssh"
show_version(remote_conn)

remote_conn.send("exit\n")
time.sleep(5)
output = remote_conn.recv(65535)
print output
ssh.close()#Closing the connection

except paramiko.AuthenticationException:
print("User or password incorrect, Please try again!!!")

Posted in Python | Leave a comment

How to run URT bundle on ISE

URT bundle can be used to check if the upgrade will be successful or not.  We can fix the error and then can schedule a window to ugrade the ISE.

Step 1> Create a repository on the ISE node

Step 2> Download the URT bundle from ISE.

Step 3> Upload the URT bundle on repository.

Step 4> Run the URT bundle on secondary node or on standalone node.

application install <URT file name > <repository name>

If for some reason the URT fails it will create a file share that file with TAC for further troubleshooting.

URT-Fail

 

Posted in ISE | Leave a comment

Send ACL logs to syslog in ASA

If you want to log the traffic allowed by an ACL on ASA to syslog server.

Step 1> You need to create ACL and add log keyword in ACL entry

access-list vlan3-5 extended permit ip host 10.5.3.189 host 10.5.5.189 log debugging

Here I have used “log debugging” you can use as per your requirement.

Step 2> Configure ASA to send the logs to syslog server:

logging enable
logging timestamp
logging list syslogmsg message 106100
logging list syslogmsg message 302013
logging list syslogmsg message 302014
logging list syslogmsg message 302020
logging list syslogmsg message 302021
logging trap syslogmsg
logging host vlan3 10.3.3.247

302020 Build inbound ICMP
302021 Tear down ICMP
302013 Build inbound TCP
302014 Tear down TCP
302015 Build inbound UDP
302016 Tear down UDP

710003 TCP denied by ACL

Posted in ASA | Leave a comment

Shell Script basics

Special variable

Lets say you have a script “script.sh” Now if you run the script as “./script.sh par1 par2”

Following is the content of the script.sh. Here $0, $1, $2 are special variable.

echo $0
echo $1
echo $2

Output of the script:

./script.sh
par1
par2

Print date in shell script:

date +%Y_%m_%d_%H%M%S
2018_09_20_231816
Posted in Other, Shell | Leave a comment

How to in MAC book

In windows operating system you can log the putty session. Now to do the same in MAC you have to do following:

Step 1> Open terminal and go to preferences:

Screenshot at Sep 10 11-05-12

Step 2> Add following in run command under profile:

FORMATTED_DATE=`/bin/date “+%Y-%m-%d%H%M%S”`;/usr/bin/script ~/Desktop/Logs/Terminal/terminal_$FORMATTED_DATE.log

Screenshot at Sep 10 11-06-26

Posted in MAC | Leave a comment

Enable or disable debug on CISCO ISE (Identity service engine)

This post demonstrate how to enable or disable debug on CISCO ISE.

Disable all debug of a node:

Go to Administration > System > Logging > Debug Log configuration > Select the node and then click on Reset to default

Following screenshot is for standalone node however procedure will be the same for nodes in deployment.

Enable or disable debug

Enable or disable debug-a

Disable individual debug of a node.

Go to Administration > System > Logging > Debug Log configuration > Select the node and then click on the name of the node

Enable or disable debug-1

Once you click on the name of the node you will get following page. Now select the component for which you want to disable the debug and then click on Reset to default.

Enable or disable debug-4

Enable debug for a component:

Go to Administration > System > Logging > Debug Log configuration > Select the node and then click on the name of the node

Enable or disable debug-1

Find out the component for which you have to enable debug. Now double click on below highlighted

Enable or disable debug-2

Select the log level which you want to set and then click on save.

Enable or disable debug-3

Posted in CISCO, ISE, Other | Leave a comment