# How to secure ssh accessible from the internet

**URL:** <https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257>\
**Category:** SLES Configure-Administer\
**Created:** [November 29, 2018, 5:32pm UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257 "2018-11-29T17:32:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![berndgsflinux](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@berndgsflinux](https://forums.suse.com/u/berndgsflinux)\
**Post date:** [November 29, 2018, 5:32pm UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257/1 "2018-11-29T17:32:04Z")

</div>

Hi,

for a scientific project we need to open the ssh port to the internet for some collaborators. Their ip’s are not always the same, so we can’t restrict the access depending from the source ip.  
My idea to secure it is to always install the latest updates, forbid root login and run ssh on a non-standard port.  
Do you have further ideas ? chroot ?

Thanks.

Bernd

---

<div class="post-metadata">

**Author:** ![ab1](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@ab1](https://forums.suse.com/u/ab1)\
**Post date:** [November 29, 2018, 11:00pm UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257/2 "2018-11-29T23:00:21Z")

</div>

On 11/29/2018 08:34 AM, berndgsflinux wrote:[color=blue]

> for a scientific project we need to open the ssh port to the internet  
> for some collaborators. Their ip’s are not always the same, so we can’t  
> restrict the access depending from the source ip.  
> My idea to secure it is to always install the latest updates, forbid  
> root login and run ssh on a non-standard port.  
> Do you have further ideas ? chroot ?[/color]

That is what I would do. if your users are able to do  
slightly-more-complex things (not really hard at all, just not as  
intuitive as passwords) you can deny password-based authentication  
entirely and have them authenticate with keys. It’s actually much nicer,  
as they’ll never be prompted to type in a password again, and it’s much  
more secure than their passwords.

Other options in the realm closer to “security by obscurity” is you could  
implement port knocking so, by default, the SSH port is not available at  
all, but once somebody “knocks” their one IP will be open.

Also, you could/should implement fail2ban so if somebody at a particular  
IP tries brute forcing their way past a password prompt, they are  
fairly-quickly shutdown. Note that this can implement legitimate users  
with bad typing techniques, thus another reason to use keys for  
authentication.

–  
Good luck.

If you find this post helpful and are logged into the web interface,  
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the  
forum as I do not use the web interface often.

---

<div class="post-metadata">

**Author:** ![KEVIN1](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@KEVIN1](https://forums.suse.com/u/KEVIN1)\
**Post date:** [November 30, 2018, 12:00am UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257/3 "2018-11-30T00:00:33Z")

</div>

berndgsflinux wrote:  
[color=blue]

> My idea to secure it is to always install the latest updates, forbid  
> root login and run ssh on a non-standard port.[/color]

As ab suggested, your best option is key authentication.  
[https://www.suse.com/documentation/sles-12/book\_security/data/sec\_ssh\_authentic.html](https://www.suse.com/documentation/sles-12/book_security/data/sec_ssh_authentic.html)

If you disable all logins, then using keys is the only way to  
authenticate. That should provide all the security you need however  
that doesn’t stop the many attempted logins that are inevitable on port  
22.

Use your firewall to:

- Block port 22
- Choose an obscure high port and port forward to port 22.

This way you won’t even need to change your default ssh port and it is  
unlikely you will find many, if any, attempted logins.

–  
Kevin Boyle - Knowledge Partner  
If you find this post helpful and are logged into the web interface,  
please show your appreciation and click on the star below this post.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Jens-U](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jens-U](https://forums.suse.com/u/Jens-U)\
**Post date:** [December 3, 2018, 11:43pm UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257/4 "2018-12-03T23:43:40Z")

</div>

Hi Bernd,

on top of the valuable responses so far, I’d recommend to set this up as an additional sshd, with its own configuration, that will only permit those well-known users by name (see “AllowUsers” option for sshd\_config). Restrict the “standard” sshd to internal interfaces (option “ListenInterface”) and the extra sshd to the Internet interface.

Or to make things more secure - could you set up a “jump host”, completely separate from your application host and reachable via ssh from the Internet, that will only allow an outgoing ssh connection after a second-factor authentication?

How hard do you need to make things, how valuable is your content?

Regards,  
J

---

<div class="post-metadata">

**Author:** ![Andreas1](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Andreas1](https://forums.suse.com/u/Andreas1)\
**Post date:** [December 14, 2018, 11:36pm UTC](https://forums.suse.com/t/how-to-secure-ssh-accessible-from-the-internet/33257/5 "2018-12-14T23:36:24Z")

</div>

Restrict network access to the ssh server with a VPN tunnel solution (StrongSwan or OpenVPN). For secure SSH see:  
[https://infosec.mozilla.org/guidelines/openssh](https://infosec.mozilla.org/guidelines/openssh)
