LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2011, 04:40 PM   #1
agriz
Member
 
Registered: Nov 2011
Posts: 195

Rep: Reputation: Disabled
SSH to new port, unable to login


Code:
## Change to other port is recommended 
Port 1212 
 
## Sets listening address on server. default=0.0.0.0
#ListenAddress 192.168.0.1
 
## Enforcing SSH Protocol 2 only
Protocol 2
 
## Disable direct root login, with no you need to login with admin user, then "su -" you into root
PermitRootLogin yes
 
##
UsePrivilegeSeparation yes
 
##
AllowTcpForwarding no
 
## Disables X11Forwarding
X11Forwarding no
 
## Checks users on their home directority and rhosts, that they arent world-writable
StrictModes yes
 
## The option IgnoreRhosts specifies whether rhosts or shosts files should not be used in authentication
IgnoreRhosts yes
 
##
HostbasedAuthentication no
 
## RhostsAuthentication specifies whether sshd can try to use rhosts based authentication. 
RhostsRSAAuthentication no
 
## Adds a login banner that the user can see
Banner /etc/motd
 
## Enable / Disable sftp server
#Subsystem      sftp    /usr/libexec/openssh/sftp-server
 
## Add users that are allowed to log in
AllowUsers someuser
PermitRootLogin yes
I have to change it later no. If the someuser login works, i will change it to no.
I created that someuser with the following command
adduser someuser && passwd someuser

But when i try to connect using that port with root or someuser, i am getting error. I am not able to connect.

Why that so?
 
Old 11-30-2011, 05:48 PM   #2
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Quote:
i am getting error
Post that error in your question.
 
Old 11-30-2011, 05:53 PM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
What is the error that you are getting when you try to connect?

Is anything else already using port 1212?

Do you have a firewall set up to disallow connections?

If you set the port to 22, does that work?

If you run this, what does it return?:

Code:
netstat -anp | grep 'LISTEN ' | grep -E '22|1212'
 
Old 11-30-2011, 10:53 PM   #4
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
Quote:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5832/sshd
tcp 0 0 :::22 :::* LISTEN 5832/sshd
It is minimul new centos 6.
I can see only selinux.

Error means, I am not allowed to login, It asks password again and again.
I am trying it in a new putty client.

When i replace the new config with old one, I am allowed to login.
 
Old 11-30-2011, 11:47 PM   #5
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
It's running on port 22.

You need to restart SSHD for your changes to port to take effect.
 
Old 11-30-2011, 11:50 PM   #6
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
Actually replaced the original config file now.
I will create a new config and post the result to you now.

Yes, I restart sshd everytime i make changes.
 
Old 12-01-2011, 12:07 AM   #7
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
tcp 0 0 0.0.0.0:2499 0.0.0.0:* LISTEN 9526/sshd
tcp 0 0 :::2499 :::* LISTEN 9526/sshd

I tried different port now.
But i am still not able to login
 
Old 12-01-2011, 12:15 AM   #8
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Check logs for messages about your logins:

Quote:
# tail -30 /var/log/secure
Do you have firewall? Check iptables rules:

Quote:
# iptables -L
 
Old 12-01-2011, 12:21 AM   #9
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
I don't think i have firewall now.
I have install it once securing ssh.

I can see login attempts from few ips in the log

Quote:
Nov 30 21:51:00 sv1 su: pam_unix(su:session): session closed for user someuser
Last three try

Quote:
Nov 30 22:04:49 sv1 sshd[5832]: Received signal 15; terminating.
Nov 30 22:08:15 sv1 sshd[9553]: Server listening on 0.0.0.0 port 22.
Nov 30 22:08:15 sv1 sshd[9553]: Server listening on :: port 22.
PS : Is it safe to display log info here?
 
Old 12-01-2011, 12:30 AM   #10
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
I meant the logs relevant to your login attempts - "Server listening on :: port 22" is irrelevant.

# tail -100 /var/log/secure | grep someuser
 
Old 12-01-2011, 12:33 AM   #11
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
This is what i found

Quote:
Nov 30 21:09:49 sv1 su: pam_unix(su:session): session opened for user someuser by root(uid=0)
Nov 30 21:11:23 sv1 su: pam_unix(su-l:session): session opened for user someuser by root(uid=0)
Nov 30 21:50:57 sv1 su: pam_unix(su-l:session): session closed for user someuser
Nov 30 21:51:00 sv1 su: pam_unix(su:session): session closed for user someuser
 
Old 12-01-2011, 12:43 AM   #12
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
I just got it working.
Instead of deleting the default config file, I just modified the port and PermitRootLogin no
It is working now.

I have some questions. Please guide me
 
Old 12-01-2011, 12:43 AM   #13
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
What is this thread doing in 'Security' I've no idea. Needs to be moved to 'Newbie'

Last edited by klearview; 12-01-2011 at 12:44 AM.
 
Old 12-01-2011, 12:47 AM   #14
agriz
Member
 
Registered: Nov 2011
Posts: 195

Original Poster
Rep: Reputation: Disabled
Quote:
UsePrivilegeSeparation yes
AllowTcpForwarding no
X11Forwarding no
StrictModes yes
IgnoreRhosts yes
HostbasedAuthentication no
RhostsRSAAuthentication no
These are the values i got from internet. I my first post, i have added those.

I just used now default config file.
Default config file has different values and some values are not available at all.

Is it good just disabling root login and changing the port?
What those config means?
 
Old 12-01-2011, 12:54 AM   #15
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Quote:
Originally Posted by agriz View Post
These are the values i got from internet. I my first post, i have added those.
Do not mess with config files until you understand what you're doing. I guarantee you that your system will be more secure if you change nothing at all than screw around by copy/pasting things from the Net without understanding their effects.
 
1 members found this post helpful.
  


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
[SOLVED] Unable to login as root through SSH satya123 Linux - Newbie 24 04-14-2011 01:54 AM
Is it okay change port login ssh >10000 ??? b-RAM Linux - Security 12 09-01-2010 05:00 PM
Unable to login via console or SSH predatorz Fedora 8 01-07-2008 01:17 AM
Unable to login via console or SSH predatorz Linux - General 3 01-05-2008 08:23 AM
SSH login on port 80 Braynid Linux - Newbie 7 07-24-2006 06:22 PM


All times are GMT -5. The time now is 11:54 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration