LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cannot login sshd with another port (https://www.linuxquestions.org/questions/linux-software-2/cannot-login-sshd-with-another-port-908924/)

tgf2 10-19-2011 04:52 AM

cannot login sshd with another port
 
1.ok,stop selinux, stop iptables
#/etc/init.d/iptables stop

2.change sshd port and restart
in /etc/ssh/sshd_config:
Port 5050

3.check the port working
#netstat -ntlp | grep :5050

4.login on server localhost
#ssh -vv -p 5050 localhost
it works.

but, on pc client

ssh -vv -p 5050 [server_name]
....

debug1: Connecting to zhuanfa [223.*.*.*] port 5050.
[stop here, no more output]

but -vv -p 22 [server_name] is ok.

stevellion 10-19-2011 05:02 AM

So, let me get this right - it still connects on port 22?

Can you try changing IPtables, rather than just stopping it - so it uses 5050 instead?

eSelix 10-19-2011 05:05 AM

Check
Code:

netstat -ntlp | grep :22
Should be empty. Did you connect this client PC through router? Maybe it has firewall or port forwarding.

tgf2 10-19-2011 05:08 AM

Quote:

Originally Posted by stevellion (Post 4502274)
So, let me get this right - it still connects on port 22?

Can you try changing IPtables, rather than just stopping it - so it uses 5050 instead?

yes, i had try to changing iptabels.
i had set sshd to listen on port 22, or 5050, or both.

but it doesn't work.
so i stop iptables, disable selinux

tgf2 10-19-2011 05:14 AM

Quote:

Originally Posted by eSelix (Post 4502280)
Check
Code:

netstat -ntlp | grep :22
Should be empty. Did you connect this client PC through router? Maybe it has firewall or port forwarding.

server side's sshd listen on port 22 before.
so i can login to server and change the default port to 5050.

i try to login with anthor client, using the new port 5050.
but connection time out.

i had try to change iptables, selinux, but it doestn't work.

wpeckham 10-19-2011 12:28 PM

sshd
 
It is not either-or, you can make sshd listen on two ports.
What you cannot do is make a dynamic change, you have to bounce or refresh sshd to have it pick up configuration changes. Did you?

tgf2 10-19-2011 03:57 PM

Quote:

Originally Posted by wpeckham (Post 4502696)
It is not either-or, you can make sshd listen on two ports.
What you cannot do is make a dynamic change, you have to bounce or refresh sshd to have it pick up configuration changes. Did you?

i login to server with port 22.
and then change /etc/ssh/sshd_config ,set Port to 5050
and /etc/init.d/sshd restart

unSpawn 10-19-2011 05:14 PM

Quote:

Originally Posted by tgf2 (Post 4502262)
stop selinux

Don't need to. Just 'semanage port -a -t ssh_port_t -p tcp 5050' to add port TCP/5050.


Quote:

Originally Posted by tgf2 (Post 4502262)
stop iptables

Don't need to. Just 'iptables -A INPUT -i eth0 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT'.


Quote:

Originally Posted by tgf2 (Post 4502262)
but -vv -p 22 [server_name] is ok.

BTW you didn't post actual output of 'ssh -v -v -v servername -p 5050' nor answer wpeckham's question abotu restarting sshd...

tgf2 10-19-2011 05:25 PM

Quote:

Originally Posted by unSpawn (Post 4502904)
Don't need to. Just 'semanage port -a -t ssh_port_t -p tcp 5050' to add port TCP/5050.



Don't need to. Just 'iptables -A INPUT -i eth0 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT'.



BTW you didn't post actual output of 'ssh -v -v -v servername -p 5050' nor answer wpeckham's question abotu restarting sshd...

thanks.
i had try what you said. but it doestn't work. so i stop them rudely.
i had restart sshd.

and the output of ssh -vv servername -p 5050 is:
OpenSSH_5.5p1, OpenSSL 1.0.0e-fips 6 Sep 2011
debug1: Reading configuration data /home/tgf6/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to zhuanfa [223.*.*.*] port 5050.


and i found out that if the server listen on not well-known port like 8080,5000
the client cannot connect to .
so is it the iptables problem?

unSpawn 10-19-2011 05:53 PM

Quote:

Originally Posted by tgf2 (Post 4502915)
it doestn't work.

Likely well-meant but unfortunately "doesn't work" doesn't contain the kind of technical details I can do anything with.


Quote:

Originally Posted by tgf2 (Post 4502915)
so is it the iptables problem?

Don't know. Could do with more nfo to start with.
On the client run:
- connectivity: 'hping2 -n -V -I eth0 --scan 22,5050 -S servername'
- firewall: 'for TABLE in $(</proc/net/ip_tables_names); do /sbin/iptables -t $TABLE -n -L; done;'.
Now on the server run:
- just to make sure: 'service sshd restart'
- 'for TABLE in $(</proc/net/ip_tables_names); do /sbin/iptables -t $TABLE -n -L; done;'
- ports opened by SSH daemon: 'lsof -Pwlnp `pgrep sshd` -a -i;'
- tcp_wrappers: 'grep -v ^# /etc/hosts.*|grep .;'
- 'grep -v ^# /etc/ssh/sshd_config|grep .;'
- enabled?: 'selinuxenabled; echo $?;'
- port assignments?: 'seinfo -p|grep ssh;'.


All times are GMT -5. The time now is 09:00 AM.