LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2017, 11:50 AM   #1
cellranking
Member
 
Registered: Jan 2016
Location: washington
Posts: 51

Rep: Reputation: Disabled
connection


Hi Room

I want to see my ssh connection from port 22. below command give current now but I want to check past 5 minutes or may be longer time frame.

thank you


netstat -tn 2>/dev/null | grep :22 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head

Last edited by cellranking; 04-20-2017 at 12:27 PM.
 
Old 04-20-2017, 12:21 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,235
Blog Entries: 3

Rep: Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710
The script you show has nothing to do with port 22.

Can you explain in a little more detail which information you are trying to collect? In all likelihood you will have to set up something explicitly to monitor the connections since netstat does not work retroactively.
 
Old 04-20-2017, 12:31 PM   #3
cellranking
Member
 
Registered: Jan 2016
Location: washington
Posts: 51

Original Poster
Rep: Reputation: Disabled
I just want to see from A time frame to B time frame has any connection from port 22.
 
Old 04-20-2017, 12:45 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,235
Blog Entries: 3

Rep: Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710
From or to port 22?

If you want to log the duration of the SSH connections, you could use xinetd to launch sshd instead of daemonized. It is one of the configuration options, specifically DURATION. See the manual pages for xinetd.conf and xinetd and sshd. The SSH daemon will need the -i option if you go that route.

Or else you could use tcpdump to try to catch the start and end packets for the various connections.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow internet connection on multiple linux distros but fast connection on windows Preston3050 Linux - Networking 1 10-29-2013 12:03 PM
mysql driver unable to create a connection due to an inabilityto establish connection jayakumar01 Linux - Server 1 01-04-2012 09:04 AM
ssh: connection to host port: 22: Connection timed out lost connection cucolin@ Linux - Server 4 11-22-2011 06:15 AM
[SOLVED] DSL connection slow on Linux wired connection but fast on Windows wireless Pandarsson Linux - Wireless Networking 9 12-17-2010 05:55 PM
vsftpd not working: Connection attempt failed with "ECONNREFUSED - Connection refused davidlu766 Linux - Server 7 05-03-2010 08:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration