LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-29-2019, 01:06 AM   #1
LT72884
Member
 
Registered: Jul 2012
Posts: 151
Blog Entries: 1

Rep: Reputation: Disabled
how it gets back to me


Ok, i come here because i like it here and i trust yall. Please forgive this question. Belive it or not, i was a ccna and took the first ccnp test.... 12 years ago haha.so its been a while

here is my question i used to know the answer to:

Lets say one of my friends have an ssh server setup and they make me a username and pass.

now, i use winscp, input his public ip or domain, enter my credentials, and hit connect. The request is sent OUT my router, travels the core, hits HIS router where the ACL checks to see if port 22 is accepting calls. It is, it sends back an auth, and then i am able to connect. A threeway handshake has been done.

where my question is, by default, i KNOW my router is not accepting calls on port 22, so how can i connect when HIS server sends back the auth? wouldnt my router block that?

i have not port forward anything in my router. I purposfully set it to default so i can figure this out. I know it works but i forget how.

thanks
 
Old 05-29-2019, 01:23 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,965

Rep: Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332Reputation: 7332
your router opened a connection to the other router. The answer will be sent back on the same line, the other router will just use the existing connection. Your router will recognize if the package arrived is an answer therefore allowed to accept and forward it "on the line" back to the initiator - which is your host.
The connection is bidirectional.
 
Old 05-29-2019, 10:03 AM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
What pan64 said is correct, but to clarify:
Connecting to a remote server on his port 22 does not mean that you are using port 22 on your 'puter.

I'm currently ssh'd into my server and netstat there says the foreign address (my local public IP address) is using port 59364 to connect to the remote port 22

Last edited by scasey; 05-29-2019 at 10:04 AM.
 
1 members found this post helpful.
Old 05-29-2019, 11:16 AM   #4
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
What pan64 and scasey said: all outbound connections are tracked by your router/firewall so when the traffic comes back, it knows where to come back to.
 
Old 05-29-2019, 11:19 AM   #5
LT72884
Member
 
Registered: Jul 2012
Posts: 151

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
What pan64 said is correct, but to clarify:
Connecting to a remote server on his port 22 does not mean that you are using port 22 on your 'puter.

I'm currently ssh'd into my server and netstat there says the foreign address (my local public IP address) is using port 59364 to connect to the remote port 22
WORD! thats right, my PC wont be using port 22, it will be a port between 1-64000 but not 22. Ok, that makes way more sense now.

Also, when pan64 said the line is bi-directional, that clicked as well. Been a fat minutes guys! haha.

Speaking of ssh, can you piggy back ssh on another port such as 80? lets say i had a server at my student apartment, campus does not allow access to router or port 22, could i somehow have ssh piggy back on port 80 since that one is allowed IN?

thanks
 
Old 05-29-2019, 11:33 AM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You can configure sshd to run on any port. I don’t run it on port 22. You can’t run two daemons on the same port, however, so if you’re running a web server on port 80, you couldn’t also run sshd there.
 
Old 05-29-2019, 11:38 AM   #7
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Personally I avoid running SSH on port 22 as I don't like my log files growing exponentially by the second. Of course, to an experienced attacker changing the port means nothing but it really keeps the script kiddies from "trying the handles" every two minutes -- I know because I once ran a sacrificial VM with SSH on port 22 and the logs were huge.
 
1 members found this post helpful.
Old 05-30-2019, 01:15 PM   #8
LT72884
Member
 
Registered: Jul 2012
Posts: 151

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
ok, let me reword what im trying to say haha. I never run ssh on port 22, usually port 5022, BUT since i do not have access to the router, and they do allow port 80 in, could i just run ssh on port 80 so that way at least it not blocked by the xfinity router? Its a basic xfinity router that the land lord owns and will not give me access to it or do any kind of configs to it. I do know that default ports are not being blocked.

Just trying to get ssh up and running (again) with out having to punch a hole in the FW. I want to use an all-ready allowed port

thanks for the ideas and help

Last edited by LT72884; 05-30-2019 at 01:18 PM.
 
Old 05-30-2019, 03:59 PM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by LT72884 View Post
ok, let me reword what im trying to say haha. I never run ssh on port 22, usually port 5022, BUT since i do not have access to the router, and they do allow port 80 in, could i just run ssh on port 80 so that way at least it not blocked by the xfinity router? Its a basic xfinity router that the land lord owns and will not give me access to it or do any kind of configs to it. I do know that default ports are not being blocked.

Just trying to get ssh up and running (again) with out having to punch a hole in the FW. I want to use an all-ready allowed port

thanks for the ideas and help
Residential (making presumption here) ISPs don't typically open port 80 (or port 25), to prevent residential customers from using their services to host public servers. I don't know about other ports, but I'd think many would have to be open for outbound things to work.

Do you think port 80 is open because you're hosting a website and it's publicly accessible?
Or because you can access the internet with a browser? Just as with ssh and 22, you're not using port 80 to browse the web. My current connection from this PC to my web server is on my local port 45992, connected to port 443 on the server (the website is secure)

Have you tried to use 5022, or an even higher port, say above 20000, for ssh?
 
Old 05-30-2019, 04:29 PM   #10
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Port 80 is allowed in on your ISP's router they rent to you? That's horrible. You can't just SSH into an arbitrary port. A port and the service using that port are tied together when the service is set up. Port 80 is for HTTP. Just because a port is open, you cannot use any service you would like with that port. Make sense? If you control the device or OS that hosts the service, then you can assign any service to any port, but that's silly and confusing: certain services use certain ports for standardization. There is zero security reason to switch a service to another port to "hide" it.
 
Old 05-30-2019, 04:40 PM   #11
LT72884
Member
 
Registered: Jul 2012
Posts: 151

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by sevendogsbsd View Post
Port 80 is allowed in on your ISP's router they rent to you? That's horrible. You can't just SSH into an arbitrary port. A port and the service using that port are tied together when the service is set up. Port 80 is for HTTP. Just because a port is open, you cannot use any service you would like with that port. Make sense? If you control the device or OS that hosts the service, then you can assign any service to any port, but that's silly and confusing: certain services use certain ports for standardization. There is zero security reason to switch a service to another port to "hide" it.
port 80 is http right? so if i access someones web server, such as yours, its going to leave my PC on port <RANDOM> destined for 80, and return on <RANDOM> and now i see your point... damn.. LOL

So if it can return on <RANDOM> why cant i assign a service to a port that is not being blocked? Is it because MY pc did not make the initial request on <RANDOM> that the FW is blocking that inbound becasue MY pc never made that request in the first place?

hmm, im begining to remember my ccnp classes from 10 years ago.. You dont use it, you lose it haha
 
Old 05-30-2019, 04:42 PM   #12
LT72884
Member
 
Registered: Jul 2012
Posts: 151

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Residential (making presumption here) ISPs don't typically open port 80 (or port 25), to prevent residential customers from using their services to host public servers. I don't know about other ports, but I'd think many would have to be open for outbound things to work.

Do you think port 80 is open because you're hosting a website and it's publicly accessible?
Or because you can access the internet with a browser? Just as with ssh and 22, you're not using port 80 to browse the web. My current connection from this PC to my web server is on my local port 45992, connected to port 443 on the server (the website is secure)

Have you tried to use 5022, or an even higher port, say above 20000, for ssh?
port 80 is http right? so if i access someones web server, such as yours, its going to leave my PC on port <RANDOM> destined for 80, and return on <RANDOM> and now i see your point... damn.. LOL

So if it can return on <RANDOM> why cant i assign a service to a port that is not being blocked? Is it because MY pc did not make the initial request on <RANDOM> that the FW is blocking that inbound becasue MY pc never made that request in the first place?

hmm, im begining to remember my ccnp classes from 10 years ago.. You dont use it, you lose it haha


Yes, i used 8022 as my go to, but the router, even with FW set to low security, blocks it. I mean, i can go to the routers gui and see SOME things like its low security, but thats it
 
Old 05-30-2019, 05:13 PM   #13
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by LT72884 View Post
Yes, i used 8022 as my go to, but the router, even with FW set to low security, blocks it. I mean, i can go to the routers gui and see SOME things like its low security, but thats it
I thought you didn't have access to the router?
Are you sure it's not the firewall on your server that's blocking rather than the router? 5022 or 8022 wouldn't typically be open on the server's firewall. Do you run selinux? That's another place it could be blocked. How are you sure it's the router?

+1 to 273's post and I respectfully disagree with sevendogsbsd -- security by obfuscation is a good additional step to firewalls and anti-cracking tools like fail2ban. I run sshd on a non-standard port and have never even had an attempt at cracking...so no logs full of Chinese IP addresses

I do agree with sevendogsbsd that trying to use non-standard ports for things like email or web services would be very limiting, although it is often done: Webmin's server uses non-standard ports (and I don't use its default port there, either), and putting things like myphpadmin on a non-standard port is also good additional security.
 
Old 05-30-2019, 05:39 PM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by sevendogsbsd View Post
You can't just SSH into an arbitrary port. A port and the service using that port are tied together when the service is set up. Port 80 is for HTTP. Just because a port is open, you cannot use any service you would like with that port.
Of course you can. An HTTP server will, by convention, listen on port 80, and an HTTP client will, by default, try to connect to port 80. You can tell the HTTP server to listen on any idle port (port where you don't have any other server currently listening), and you can tell an HTTP client to attempt a connection to any port (port 8080 is a common alternate). The same is true for SSH. It's just that if you are using a nonstandard port, anyone trying to connect will have to specify the port explicitly.
Quote:
There is zero security reason to switch a service to another port to "hide" it.
True enough, but it does greatly cut down on the log noise from script kiddies that try SSH connections to port 22 on every IPv4 address on the internet.
 
2 members found this post helpful.
Old 05-30-2019, 09:42 PM   #15
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
I may have not made myself clear. Yes, changing a service to a non standard port will keep the script kiddies away but a professional will scan all ports, finding the service that is "hidden". I find things web masters attempt to hide every day at work because that's what I am paid to do. I do get that the majority of bad traffic out there is script kiddies and cutting down on the traffic "noise" is a good thing. I am used to security being all out, so anything less I tend to question.

rknichols - you cannot SSH to an arbitrary port where SSH is not running - that's what I should have said and what I meant. I was trying to correct the OP's statement "and they do allow port 80 in, could i just run ssh on port 80" because the implication there was because the port is open, you can use any service on that port, which is of course, not true: you can only access that port using the service running on that port.

Sorry if I wasn't clear.
 
  


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
LXer: Solus Gets a Really Good Week, Gets First RC and Firefox Compliance LXer Syndicated Linux News 0 11-01-2015 08:03 PM
LXer: KLook gets PDF/ODT support, while StackFolder gets drag-n-drop LXer Syndicated Linux News 0 06-29-2012 08:41 AM
LXer: Android gets SDXC flash driver, Microsoft gets royalties LXer Syndicated Linux News 1 06-03-2010 01:43 PM
Kubuntu Feisty Fawn ICS, X360 gets no DNS, laptop gets no internet drache777 Linux - Networking 0 05-12-2007 07:16 PM
Gnome: root gets v2.6 but user gets v2.4 alexc Linux - Newbie 4 04-21-2004 12:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:03 AM.

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