-8

I simply want to block all ssh connections on Linux. How can I proceed? My question is rather simple, so I see no point in providing excess nonsense. I tried to research and none of what I tried works, so please provide me with exact instructions.

  • 1
    Listing what you tried and the resulting errors is not considered 'excess nonsense'. Especially for a basic task like this. – Panki Nov 7 at 15:49
  • 1
    As @Panki said, especially if you require exact instructions. Such instructions can't be given without knowledge of e.g. what Linux distribution (and release) you are using, what type of firewall software you are running. If you want to shut down the SSH daemon completely or just filter the SSH port for certain networks/hosts, you should add that. – Kusalananda Nov 7 at 15:51
  • Please mention your distribution, whether you are using openssh or libressh (if you are not sure, it's probably openssh) and whether it's installed from source or with a package (if you are not sure, it was probably a package) – Garo Nov 7 at 16:00
1

There are a few ways to do this

  • Stop the SSH server (the exact command may vary, depending on distro and installed ssh server)

    systemctl stop sshd
    
  • Use the firewall to block your SSH port, default 22 (this example is for ufw)

    ufw block 22 && ufw reload
    
  • Disable networking altogether (pull the plug, rf kill switch...)

  • Once I run these commands it will pervent any ssh operations to my computer so no one with the password can remotely access my computer ever again? If not than I need more help – Julian Tiemann Nov 7 at 15:50
  • Well, are you running any other services which are listening? – Panki Nov 7 at 15:51
0

The simplest way of all to block all ssh connections is to remove just remove the ssh-server...

In most cases (Ubuntu, Mint, Debian and similar distributions) this will be apt purge openssh-server.

I'm saying "most cases" because there are some cases (mentioned below) where removing the ssh-server works different (but this will probably not be the case on your system):

  • You are not using openssh but libressh or another sshserver
  • You did't install it using a deb-package

But as mentioned, normally you don't have to worry about this... Otherwise, rephrase your question.

-2

Why don't you stop sshd altogether?

  • 1
    What? How do I do that? Whatever happened to "Exact instructions" – Julian Tiemann Nov 7 at 15:48
  • You're expected to do your homework, at least at the basic level. You don't offer any info about your environment, considering it "excess nonsense", yet you expect exact instructions. Not really how things work. – schaiba Nov 7 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.