TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why putting SSH on another port than 22 is bad idea

26 pointsby justinwrover 11 years ago

18 comments

16sover 11 years ago
Security through obscurity is useless. I have heard people repeat this for the last 20 years. They are wrong and they have no idea what they are talking about. They just parrot what others say. Like chaos it perpetuates itself.<p>We camouflage tanks. We build stealth fighters. If obscurity had zero value, we&#x27;d just paint the tanks bright pink with hot orange flames and drop all the stealth research too. No need to sneak around. Obscurity is useless right?<p>Hide from the bear and it might not find and eat you. Move your ssh port and your logs will have less idiots out there filling them up. That fact alone is worth changing ports.<p>Obscurity has its place along side other tactics. And when you put it all together, you&#x27;ll have a more secure system.<p>So please cut the &quot;Security through obscurity&quot; crap.
评论 #6616056 未加载
评论 #6616030 未加载
评论 #6616185 未加载
评论 #6616060 未加载
评论 #6616967 未加载
评论 #6616084 未加载
评论 #6616068 未加载
评论 #6616002 未加载
nairteashopover 11 years ago
&gt; When we start SSH on port 22, we know for a fact that this is done by root. But what happens when we move SSH to port 2222? This port can be opened without a privileged account, which means I can write a simple script that listens to port 2222 and mimics SSH in order to capture your passwords.<p>Well OP is assuming that I trust the root user of the machine I am SSH&#x27;ing to. If I do, then what&#x27;s the concern? The root user probably told me what the SSH port is. If I don&#x27;t, then well what&#x27;s to say the SSH daemon on port 22 is secure? In any case, there are many other ports that are not 22 and are &lt; 1024. You don&#x27;t have to pick 2222.<p>Changing the port is not the ultimate defense against attack, but in my experience it does reduce random drive-by type attacks. Same reason you raise your windows when you lock your car - as easy as it is to break a car window, a thief would rather steal from a car with an open window than smash your windows and steal from yours.
评论 #6616129 未加载
评论 #6615988 未加载
csenseover 11 years ago
&gt; capture your passwords<p>With public key auth, an attacker can&#x27;t capture anything useful (unless of course they record traffic and later figure out a way to later capture the private key [1], but this isn&#x27;t a problem that changing the port will fix).<p>&gt; mimics SSH<p>You can&#x27;t mimic the key files in &#x2F;etc&#x2F;ssh&#x2F;ssh_host_whatever_key without root privileges, assuming these files are properly secured. So users will get an unexpected warning that the host key has changed.<p>&gt; simple script that listens to port 2222<p>True -- in cases where something isn&#x27;t already listening on 2222. But if sshd is started early in the boot process and listens on 2222, won&#x27;t any script started as a regular user be unable to bind to the socket?<p>[1] <a href="https://news.ycombinator.com/item?id=6609601" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6609601</a>
评论 #6615926 未加载
onedognightover 11 years ago
&gt; So running SSH on a non-privileged port makes it potentially LESS secure, not MORE. You have no way of knowing if you are talking to the real SSH server or not.<p>Of course you do: the SSH host keys. They are an integral part of the SSH trust model. If you blindly accept any host key thrown at you, for a machine you didn&#x27;t just boot for the first time, then nothing can help you as you can easily be man-in-the-middled <i>even if</i> you are using port 22 (say from the cafe wireless you are using).
atoponceover 11 years ago
So many problems with this article, it&#x27;s very hard to take seriously. Let&#x27;s start with not giving us reasons to protect the innocent. Oooh. Scary! He must be a real pro at security! He&#x27;s keeping secrets that are too valuable to share! Please.<p>Next, he talks about anyone setting up a script to listen on a non privileged port to collect passwords. Okay. So, are you saying I shouldn&#x27;t connect to your server then? Because if I set MY server&#x27;s SSH port on 2222, I&#x27;m not worried about anyone collecting passwords on MY server. Unless they have root. Then I have bigger problems, and they can also collect my password when logging on to port 22.<p>Also, security through obscurity is hardly useless. Sure, don&#x27;t use it as your only security defense, but it does have value. Obscurity means hiding something of value from plain sight. Can you find that object? Sure. That doesn&#x27;t mean stealth is pointless. If so, we wouldn&#x27;t have camouflage, stealth bombers, and the NSA. Stealth can be be valuable.<p>Lastly is keys over passwords. Again, unless you have root on the box, you&#x27;re not getting the login password without brute force, or some protocol vulnerability. And, if your password is weak, what makes you think using keys is any stronger? First, you can create SSH keys without encrypting it with a password. If you choose to encrypt it with a password, what makes you think that password will be any stronger? Sure, remote password brute forcing us infeasible, but scanning Github for private keys isn&#x27;t. What&#x27;s one server versus another, unless you&#x27;re targeting the user?<p>No, this article isn&#x27;t thought through.
InclinedPlaneover 11 years ago
I put SSH on a different port because it cuts down on the drive by login attempts. I don&#x27;t have random users on my systems so I don&#x27;t care that it&#x27;s possible for non-priveleged users to listen on high ports, there shouldn&#x27;t be anything listening on any port on my systems without my knowing about it. And I don&#x27;t use running ssh on a different port as an excuse for lax security.<p>Under different circumstances different tradeoffs would apply, but for my current modes of use I don&#x27;t see a compelling reason to put SSH on port 22.
评论 #6615941 未加载
uncoder0over 11 years ago
If you are using passwords for auth with SSH you have already lost.
dijitover 11 years ago
This raises a few questions.<p>firstly, How does he hope to mimic SSH with a script, when most &#x27;companies&#x27; will roll out DNS sshfp records, heck, I even do it at home. -- he&#x27;d need to access the private keys in &#x2F;etc&#x2F;ssh&#x2F; to be able to do anything; unless he&#x27;s rooted my box, I don&#x27;t see how he could.<p>Secondly; he&#x27;d need to kill my sshd process in order to make his script work, sshd is not the kind of process driven behemoth that apache+modphp is, so you can&#x27;t brute force it to death- how are you going to kill it if you&#x27;re not root?<p>Finally; if you kill my sshd- where does your session go.<p>of course, all of this could be bypassed if you had root, but if you are root you can do anything anyway- you could capture and decrypt data with the private keys- surely that&#x27;d be easier.<p>(also, if you&#x27;re root you can bind port 22 anyway, so it&#x27;s a moot point)
smutticusover 11 years ago
I run SSH on a non-standard port because it makes it easier to see when someone is genuinely targetting me for attack. If I run SSH on 22 then I won&#x27;t know when someone is targetting me for attack since I&#x27;ll be under constant script kiddie attacks from everywhere all at once. If I have nothing on 22 then all those attacks just get silently blackholed. Which is ideal.
IgorPartolaover 11 years ago
The non root user issue is invalid. While I can start an ssh-like service on port 2222 as a non root user, I cannot read the private ssh server key owned by root. If the sshd got switched to one run by an unprivileged attacker, you would get a bad server fingerprint and not connect (you wouldn&#x27;t, right?).
danielrm26over 11 years ago
Here&#x27;s my response to this, point by point:<p><a href="http://www.danielmiessler.com/blog/putting-ssh-another-port-good-idea" rel="nofollow">http:&#x2F;&#x2F;www.danielmiessler.com&#x2F;blog&#x2F;putting-ssh-another-port-...</a>
评论 #6622083 未加载
badman_tingover 11 years ago
Security through obscurity is not to be avoided outright, using <i>only</i> security through obscurity is to be avoided outright. If you have an otherwise secure system and then you obscure it in some ways, the worst that can happen is that it has no effect. So the problem is in thinking it alone will protect you, but it is not harmful in itself.<p>I think people throw this phrase out because it scans nicely and makes you sound like you know what you&#x27;re talking about, especially to yourself.
mh-over 11 years ago
<i>I can write a simple script that listens to port 2222 and mimics SSH in order to capture your passwords.</i><p>ignoring other authentication methods, PKI, etc..
danielrm26over 11 years ago
Obscurity is only a poor security layer if it&#x27;s used as a substitute for security instead of a supplement.<p><a href="http://www.danielmiessler.com/blog/putting-ssh-another-port-good-idea" rel="nofollow">http:&#x2F;&#x2F;www.danielmiessler.com&#x2F;blog&#x2F;putting-ssh-another-port-...</a><p>Camouflage on tanks doesn&#x27;t remove the armor; it just lowers the chance that it&#x27;ll be needed.
ams6110over 11 years ago
Running ssh on another port is typically something you do with your own machines. If you&#x27;re connecting to a foreign system, you either trust it or you don&#x27;t. The fact that ssh is on port 22 or not means nothing.
anaphorover 11 years ago
a) Nobody doing this expects that it will increase the difficulty of cracking the server via SSH, or at least nobody I&#x27;ve talked to does it for this reason and I certainly don&#x27;t. b) Since when is the uid that started a process a form of authentication? c) Who cares what the default settings are for most SSH clients? It&#x27;s trivial to put it in your config file and forget about it. d) Using port 443 for SSH is a legitimate use to get around firewalls&#x2F;traffic shapers.
nudetayneover 11 years ago
Pretty sure I&#x27;ll continue to put SSH on a non-standard port. I already monitor my systems and its their logs heavily, and this cuts down on 99% of SSH-related spam. Any attack that&#x27;s serious, the port will not matter.
Aqueousover 11 years ago
obscurity is not security. nothing&#x27;s going to stop people from portscanning your server no matter what port it is on.
评论 #6615958 未加载
评论 #6615927 未加载
评论 #6615924 未加载
评论 #6615900 未加载
评论 #6615899 未加载
评论 #6615916 未加载
评论 #6615963 未加载