LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 11-22-2006, 10:57 AM   #1
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0
Close unused ports and SSH


[Log in to get rid of this advertisement]
Hi,

Recently our security team ran port scanning on one of my server, and found some open ports, which need to be closed.

How can I closed those unused ports. (and how do i check whether anyone is using the open ports or not)

And how do i disable root login to the system using ssh. (meaning all users can ssh to the system, but they need to issue su to get root access)

Thanks.
annielee is offline  
Tag This Post , , , ,
Reply With Quote
Old 11-22-2006, 11:30 AM   #2
bit128_linux
Member
 
Registered: Dec 2005
Location: Brasov, Romania
Distribution: Slackware, Bluewhite64
Posts: 49
Thanked: 0
In the SSH daemon config file, you have a line like this:

PermitRootLogin Yes

If the line if commented(starts with #), then uncomment it and change that 'Yes' with 'No. After that, you should restart your SSH daemon.
bit128_linux is offline     Reply With Quote
Old 11-22-2006, 12:46 PM   #3
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0

Original Poster
erm..where's the ssh config file and how do i restart the ssh daemon?
annielee is offline     Reply With Quote
Old 11-22-2006, 02:16 PM   #4
bit128_linux
Member
 
Registered: Dec 2005
Location: Brasov, Romania
Distribution: Slackware, Bluewhite64
Posts: 49
Thanked: 0
Well, that depends on distribution. In Slackware Linux the file path is '/etc/ssh/sshd_config' and you restart the server with this command(executed as root, of course):

/etc/rc.d/rc.sshd restart

Please post which distribution you use along with it's version.
bit128_linux is offline     Reply With Quote
Old 11-22-2006, 11:30 PM   #5
denver1980
Member
 
Registered: Dec 2004
Location: Québec
Distribution: Red Hat 8, Fedora C2, Salckware 11.0
Posts: 46
Thanked: 0
And to know which port is opened, compare the 2 lists obtained by
Code:
$ netstat -a | grep -i listen
$ netstat -an | grep -i listen
By comparing them, you will see which service runs on what port.
If one port is numerical even in the -a list, googlize it

Hope it helps
denver1980 is offline     Reply With Quote
Old 11-23-2006, 07:40 AM   #6
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0

Original Poster
one more question, when a new user is created, by default they can ssh to the server, right??
annielee is offline     Reply With Quote
Old 11-23-2006, 11:01 PM   #7
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.5-beta, OS X 10.5.6, CentOS 4 & 5
Posts: 3,631
Thanked: 14
Yes, unless you're using the AllowUsers statement in /etc/ssh/sshd_config.
chort is offline     Reply With Quote
Old 11-23-2006, 11:52 PM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Distribution: mandriva 2009.1, 2008.1, kubuntu 8, fedora 8
Posts: 2,819
Thanked: 38
...and using the AllowUsers directive is a really, really, really good idea, from a security perspective.
jiml8 is offline     Reply With Quote
Old 11-24-2006, 08:30 AM   #9
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0

Original Poster
i've created a new user using useradd..but the new user cant login using ssh.

i didnt use AllowUsers in the sshd_config file.

please assist.
annielee is offline     Reply With Quote
Old 11-24-2006, 12:32 PM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Distribution: mandriva 2009.1, 2008.1, kubuntu 8, fedora 8
Posts: 2,819
Thanked: 38
what is the error message? Where is the user logging in from? You created the new user on the ssh server, right?
jiml8 is offline     Reply With Quote
Old 11-24-2006, 09:02 PM   #11
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0

Original Poster
it just said authentication failed. yup, i've created the user in the ssh server..
annielee is offline     Reply With Quote
Old 11-24-2006, 09:29 PM   #12
jiml8
Senior Member
 
Registered: Sep 2003
Distribution: mandriva 2009.1, 2008.1, kubuntu 8, fedora 8
Posts: 2,819
Thanked: 38
so, your new user does an "ssh myservername" and the server responds "username" and the user enters "myusername", to which the server responds "password" and the user enters "mypassword", then after a pause, the server says "authentication failed". Is that right?

Can this user log on at the server? Does this user have shell access as part of the account?

You should list the contents of your sshd_config file here.
jiml8 is offline     Reply With Quote
Old 11-28-2006, 05:36 AM   #13
annielee
LQ Newbie
 
Registered: Oct 2006
Posts: 18
Thanked: 0

Original Poster
i dun have the file with me now, (the server is at some other location).

but i didnt change the anything in the file.(it's original since day 1 after installation)
annielee is offline     Reply With Quote
Old 11-28-2006, 08:18 AM   #14
boToo
Member
 
Registered: Aug 2003
Distribution: Kubuntu
Posts: 49
Thanked: 0
You are at somewhere!! But can you log in to server with ssh? you can use putty if you are using windoes, and open sshd_config in putty, select all, and then just paste it here. It might help.
boToo is offline     Reply With Quote
Old 11-28-2006, 12:08 PM   #15
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.5-beta, OS X 10.5.6, CentOS 4 & 5
Posts: 3,631
Thanked: 14
Does the new user have a password? SSH does not allow logins with blank passwords, by default.
chort is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
Closing unused ports jasone Linux - Security 12 07-02-2005 03:49 PM
How can I close ports? nectron101 Linux - Networking 3 11-28-2004 12:22 AM
List of unused ports on a machine linuxprogrammer Linux - Newbie 2 10-18-2004 03:20 PM
List of unused ports on a machine linuxprogrammer Linux - Newbie 4 10-18-2004 03:20 PM
List of unused ports on a machine linuxprogrammer Linux - Networking 1 10-18-2004 03:42 AM


All times are GMT -5. The time now is 12:27 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration