LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > 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


Reply
  Search this Thread
Old 07-05-2012, 03:10 PM   #1
Zilvermeeuw
Member
 
Registered: Jan 2006
Distribution: Fedora 20, 21, 22, CentOS 6, CentOs 7
Posts: 92

Rep: Reputation: 17
ssh -p x still connects to port 22


I want to have ssh access to server14 through port x, and block port 22.

On my desktop, I give the command: 'ssh -p x server14', where x is above 1024.

On server14, i changed /etc/ssh/sshd_config to listen to port x (Port=x)
With switched-off the iptables on server14, I can connect with ssh. But if I have iptables running, with rule: -A INPUT -p tcp --dport x -j ACCEPT, I cannot connect.
The logging on server 14 says:
Code:
Dropped by firewall INPUT: IN=eth0 OUT=<snip> PROTO=TCP SPT=42225 DPT=22 WINDOW=14600 RES=0x00 SYN URGP=0
Whatch the DPT=22.

How is that possible??

On the desktop, I can run 'ssh -v -v -p x server14', I get:
Code:
OpenSSH_5.6p1, OpenSSL 1.0.0j-fips 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to server14 [192.168.1.74] port x.
So connecting to port x, not 22.....

How can I connect to server14, only through port x?
 
Old 07-06-2012, 11:46 AM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Well it may be possible that your ssh_config file is taking over, it shouldn't with the -p option but as an easy troubleshooting step and to make life easier you should update your /etc/ssh/ssh_config file on the client that is connecting to the server to update the port directive and specify your 1024 port.

Also, make sure you don't have any iptable translation rules on your client.
 
1 members found this post helpful.
Old 07-06-2012, 02:19 PM   #3
Zilvermeeuw
Member
 
Registered: Jan 2006
Distribution: Fedora 20, 21, 22, CentOS 6, CentOs 7
Posts: 92

Original Poster
Rep: Reputation: 17
Hi Kustom42.

It is not the ssh_config. I see in the IpTables log file of the client, the outgoing port is correct. However, in the log file of the server, the incoming port is 22 (not correct).

I did play with prerouting before: #$IPT -t nat -A PREROUTING -p tcp --dport x -j DNAT --to-destination :22
But that line is commented now.

BUT connecting with 'ssh -p y server14' (y != x), works correctly!!!
So somewhere, the forwarding (prerouting) is still active. iptables -L does not say it.

Luckily it is on a virtual test server, not on my live servers.....

Your last line did pointed me to the error. Thanks!
 
  


Reply



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
SSH Connects but no shell prompt Trd79 Linux - Server 5 08-01-2008 11:58 AM
Howto do Secured ssh from port https or port80(standard) to ssh d listening port 22 ? Xeratul Linux - General 4 11-23-2006 06:09 AM
iptables help! DROP ssh port, but allow to connect to ssh if from 2222 port kandzha Linux - Networking 4 09-13-2006 09:10 AM
telnet to port 25 connects but without reply? Pcghost Linux - Networking 13 01-19-2004 10:03 PM
SSH connects but hangs pdibona Linux - Networking 5 10-09-2002 08:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:43 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
Open Source Consulting | Domain Registration