Find duplicate keys in SSH data

cowspotter

New member
Local time
Today, 13:31
Joined
Aug 13, 2008
Messages
8
I have a table with the following columns:

Key - SSH Key value
FromAcct - Account that uses the SSH key
FromSever - Server that uses the SSH key
ToAcct - Account that is accessed using SSH key
ToServer - Server that is accessed using SSH key

We are finding that one key is being used by multiple FromAccts. I need to write a query that returns the Key, FromAcct, and ToAcct where one key value is used for 2 or more FromAccts. Can someone help me out with this?
 
A GROUP BY Statement By with a HAVING Clause sounds like it might be what you need.
Code:
SELECT Count(Key) As UsageCount, FromAcct, FromSever, ToAcct, ToServer
FROM YourTableName
GROUP BY FromAcct, FromSever, ToAcct, ToServer
HAVING Count(Key) > 1
 
First of all, I need the actual key values in the results as well so I added that to the select statement (and the group by since it has to be there as well). I removed ToServer and FromServer from the select and group by because I don't need those. The problem is that this tells me that a key may be used by user "admin" to user "root" on 2 servers, but I'm not conerned about that. I want to know which keys are being used by 2 FromAccounts. I can do a manual analysis of the results of your query to see which keys appear more than once and with different FromAccts, but I'd rather not do it that way if I can get the results to be filtered to what I'm concerned with in the first place.
 

Users who are viewing this thread

Back
Top Bottom