LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-03-2011, 03:40 PM   #1
Dave_P
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Rep: Reputation: 1
How to check log files for ssh connection attempts


I've setup a ssh server at home to do ssh tunneling so I can use my tablet on public wifi.

How I can check the logs file(s) for attempts of others trying to connect to my ssh server. btw, I am using a 5 digit number as the ssh port.

I never hardly look at any logs files because they are so cryptic to understand. I need help on what to look for whether the attempt to connect was successful or not.

Thanks

Last edited by Dave_P; 10-03-2011 at 03:45 PM.
 
Old 10-03-2011, 04:23 PM   #2
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
I have a script that runs every minute looking at the last 150 lines in auth.log.
If it finds 20 of two different messages in a sample it blocks the IP.

It used to block a few a week, but after moving off of port 22 it hasn't blocked an IP in over two and a half years, this is on three machines.

So you have already done the first best thing.

You can look for these two manually with;
Code:
cat /var/log/auth.log|grep "POSSIBLE BREAK-IN ATTEMPT"
cat /var/log/auth.log|grep "Invalid user"
To reject attacker
Code:
route add -host 202.105.135.91 reject
To remove
Code:
route del -host 74.55.98.10 reject
The routing reject will remain until reboot.
 
1 members found this post helpful.
Old 10-03-2011, 04:49 PM   #3
Dave_P
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Original Poster
Rep: Reputation: 1
thanks rustek for the helpful tip

I ran the grep commands above and no output was given. I guess my new ssh server is OK for now.

I read as much as possible about ssh tunneling before implementing it. For example, I used a different port other than the standard 22. I've used AllowUsers and added my name only.

There is something I read about using private key authentication as to password authentication. They say it is more secure. But, I don't know if I could trust something I never done before.

Anyway, I added a +1 reputation for you

Thanks

Last edited by Dave_P; 10-03-2011 at 05:47 PM.
 
Old 10-03-2011, 05:25 PM   #4
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
The private key thing works good, I had a little trouble the first time, but I use it to move stuff automatically between servers now.
 
Old 10-03-2011, 05:59 PM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Have a read through this tutorial. While a bit dated, I found it to be a good explanation of how to set up key-based authentication.
 
Old 10-04-2011, 01:09 AM   #6
Dave_P
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Original Poster
Rep: Reputation: 1
Thanks Hangdog42 for the link

I already know this, what I meant in my last post was I didn't want to take a change on trying something I haven't tried before. I always done password authentications.

Last edited by Dave_P; 10-04-2011 at 01:45 AM.
 
Old 10-04-2011, 02:02 AM   #7
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
If you don't set a password on the key, then if you loose or someone gets hold of your tablet they will be able to access the server until you remove or change the server key.

It is more secure using the key and you should password protect it if you feel the need.

You have to decide that when you create the key.

If someone steals my notebook, I have to make a phone call before they figure out they have root access to several machines.

Last edited by rustek; 10-04-2011 at 02:23 AM.
 
Old 10-04-2011, 05:43 PM   #8
Dave_P
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Original Poster
Rep: Reputation: 1
If I create this key pair, what do I do with the keys. Do both keys need to be in the .ssh directory or just one of them or could I move both off to a usb stick?
 
Old 10-04-2011, 06:07 PM   #9
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
One key in each machine, it looks like the link provided by Hangdog42 shows all that.

You probably could put a symlink in .ssh and put the key on the usb stick, neat idea.

Last edited by rustek; 10-04-2011 at 06:10 PM.
 
Old 10-04-2011, 07:22 PM   #10
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
i dont quite follow the original question, which was how to monitor for others trying to access the ssh server. then it turned into a how-to-authenticate question.

what exactly are you tunneling? a client-server app and the server is at your house?

run iptables and configure the rules and logging accordingly.

what rev/distro of linux and what sshd is it?
 
Old 10-04-2011, 10:29 PM   #11
Dave_P
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Original Poster
Rep: Reputation: 1
@ Linux_Kidd

My question was solved. I have no issues with ssh tunneling whatsoever. My question about ssh private key authentication was a after though, just asking people if it was safer than password authentication.

Sometimes threads go off topic. Anyway, I mark it as solved. Thanks to all who replied.

Last edited by Dave_P; 10-04-2011 at 10:34 PM.
 
Old 10-05-2011, 12:40 PM   #12
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Raspbian, Ubuntu, Chrome/Crouton
Posts: 374

Rep: Reputation: 50
Why wouldn't denyhosts work here?

Denyhosts monitors ssh login failures and adds the offending IP to hosts.deny.

I believe you can configure it for other port numbers, the number of long in attempts, and services. It also automatically removes offending IPs from hosts.deny after a month.

I use ssh on the standard port number with denyhosts.
 
Old 10-05-2011, 01:05 PM   #13
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
Quote:
Originally Posted by pwalden View Post
Why wouldn't denyhosts work here?

Denyhosts monitors ssh login failures and adds the offending IP to hosts.deny.

I believe you can configure it for other port numbers, the number of long in attempts, and services. It also automatically removes offending IPs from hosts.deny after a month.

I use ssh on the standard port number with denyhosts.
he uses public wifi (dhcp) so how could he know what to deny?
 
Old 10-05-2011, 01:20 PM   #14
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Raspbian, Ubuntu, Chrome/Crouton
Posts: 374

Rep: Reputation: 50
I thought he said he had a ssh server was at home. That is where the denyhosts runs.

I guess I don't understand what the set up is here.
 
Old 10-05-2011, 01:38 PM   #15
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
Quote:
Originally Posted by pwalden View Post
I thought he said he had a ssh server was at home. That is where the denyhosts runs.

I guess I don't understand what the set up is here.
yes, sshd runs at his house, but his tablet is a dhcp client that connects to various wifi ap's. his tablet runs the ssh client and he uses it to tunnel to/through his sshd at home. so if his IP changes often then hosts.deny is not robust enough. certainly he can use hosts.deny to limit a majority of inet IP but thats not a secure solution.

Last edited by Linux_Kidd; 10-05-2011 at 01:42 PM.
 
  


Reply



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
[SOLVED] iptables drop and log ssh key authenticated repeat attempts akamikeym Linux - Security 6 08-25-2011 07:27 AM
ssh...log files that store the login attempts Bgrad Linux - Networking 4 03-29-2010 09:40 AM
SSH Alert when root attempts to log gamehack Linux - Software 3 06-03-2009 06:44 AM
LXer: ssh-xfer: Quickly grabbing files over an existing SSH connection LXer Syndicated Linux News 0 08-08-2008 03:11 PM
vsftpd and log files - can i up the log level to see login attempts? robr Linux - Newbie 3 04-04-2008 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:13 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