Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-10-2005, 05:32 PM
|
#1
|
|
Member
Registered: Jun 2003
Location: Central Coast, NSW, Australia
Distribution: Gentoo
Posts: 438
Rep:
|
Logging an IP?
Hello.
This should be a simple question for you guys.
When someone ssh's into my linux box, I want it to do two things, put it in the MOTD file, and also log it somewhere so I can have a look.
Is this possible?
The reason I want it in the MOTD file is so basically it can warn the person doing so that there IP is x.x.x.x and it is being monitored.
Any ideas?
Thanks alot.
Craig 
|
|
|
|
02-11-2005, 02:24 AM
|
#2
|
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
well, i know there's a section for configuring logging in the /etc/ssh/sshd_config file... there's also an option in there for selecting if you want the MOTD to be displayed for ssh clients...
but i'm not sure how you'd make it so that their IP appears in the MOTD they receive, though...
maybe just telling them that their IP has been logged could be enough?? actually, the psychological effect of having their IP address displayed is much more powerful, so it's definitely worth it to achieve this "personalized motd" thing...
i'm sure someone knows how to do this and will post the method...
i wanna learn to do it also, if i figure it out i'll let you know...
good luck...
Last edited by win32sux; 02-11-2005 at 06:50 AM.
|
|
|
|
02-11-2005, 02:55 AM
|
#3
|
|
Member
Registered: Apr 2004
Location: ..where no life dwells..
Posts: 541
Rep:
|
...for the messages, edit
/etc/issue, /etc/issue.net
...for the logging
perhaps /var/log/secure helps you!?
there´s the ssh access listed
|
|
|
|
02-11-2005, 06:49 AM
|
#4
|
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
issue and issue.net are for local and telnet logins... sshd will usually display /etc/motd by default, AFAIK... as for the logging, on slackware the ssh login info (date, time, username, ip address, reverse dns, source port, etc.) is logged to /var/log/messages, i'm guessing it's probably the same on other distros, but i'm not sure... for the motd to display the ip address of the client you'd probably need a script to look at /var/log/messages (or wherever you're logging) and get the login's corresponding ip from there right after the login and then echo it - but i'm still not sure how to do this in a kosher manner... i suspect it could be done from the user's ~/.profile but then they'd require read permission to the logfile and that would really suck...
Last edited by win32sux; 02-11-2005 at 06:54 AM.
|
|
|
|
02-11-2005, 07:01 AM
|
#5
|
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
(thinking-out-loud) maybe we should look into the "banner" option in /etc/ssh/sshd_config... i think it might be possible to run the script from there for every user upon login... in fact, i think you could show the banner even before they enter the password, and the banner could include the IP like you want...
Last edited by win32sux; 02-11-2005 at 07:03 AM.
|
|
|
|
02-11-2005, 08:05 AM
|
#6
|
|
Member
Registered: Apr 2004
Location: ..where no life dwells..
Posts: 541
Rep:
|
Quote:
|
[B]issue and issue.net are for local and telnet logins... sshd will usually display /etc/motd by default
|
oops...you´re right! :-)
Quote:
|
.. as for the logging, on slackware the ssh login info (date, time, username, ip address, reverse dns, source port, etc.) is logged to /var/log/messages, i'm guessing it's probably the same on other distros, but i'm not sure...
|
FC is /var/log/secure
|
|
|
|
02-13-2005, 04:02 PM
|
#7
|
|
Member
Registered: Jun 2003
Location: Central Coast, NSW, Australia
Distribution: Gentoo
Posts: 438
Original Poster
Rep:
|
Hi guys,
Thanks for your replies. You are right, it does log the IP etc in /var/log/messages when someone logs in using ssh, and you can set the banner up in sshd_config, which basically runs a script that you point it to. Problem is that I'm not that good at scripting
I'll let you know if I manage to figure it out.
Thanks again.
Craig 
|
|
|
|
All times are GMT -5. The time now is 05:06 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|