LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SSH to new port, unable to login (https://www.linuxquestions.org/questions/linux-newbie-8/ssh-to-new-port-unable-to-login-916441/)

agriz 11-30-2011 03:40 PM

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?

klearview 11-30-2011 04:48 PM

Quote:

i am getting error
Post that error in your question.

rjlee 11-30-2011 04:53 PM

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'

agriz 11-30-2011 09:53 PM

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.

klearview 11-30-2011 10:47 PM

It's running on port 22.

You need to restart SSHD for your changes to port to take effect.

agriz 11-30-2011 10:50 PM

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.

agriz 11-30-2011 11:07 PM

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 :(

klearview 11-30-2011 11:15 PM

Check logs for messages about your logins:

Quote:

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

Quote:

# iptables -L

agriz 11-30-2011 11:21 PM

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?

klearview 11-30-2011 11:30 PM

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

# tail -100 /var/log/secure | grep someuser

agriz 11-30-2011 11:33 PM

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

agriz 11-30-2011 11:43 PM

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

klearview 11-30-2011 11:43 PM

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

agriz 11-30-2011 11:47 PM

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?

klearview 11-30-2011 11:54 PM

Quote:

Originally Posted by agriz (Post 4538893)
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.


All times are GMT -5. The time now is 02:49 PM.