> For the complete documentation index, see [llms.txt](https://lodestone-technologies.gitbook.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodestone-technologies.gitbook.io/knowledgebase/dedicated-hosting/change-default-ssh-port.md).

# Change default SSH port

Changing the default SSH port will help prevent an attacker from launching brute force attacks to the default port of your dedicated server. This method works on Linux, Ubuntu, and Debian.

Log in as the server as root, or execute `sudo su` to gain root access.

Check to see the status of the firewall by executing `ufw status`. If the firewall is active then you'll need to add a rule to allow connections for the new SSH port. This can be done by executing `ufw allow <newportnumberhere>/tcp`.

Execute `nano /etc/ssh/sshd_config` and look for the line that contains "Port 22"**.** Change the number "22" to any unused port you'd like. Save and exit once done.

Restart the SSH service by executing `restart ssh` within the command line. For Debian, execute `service ssh restart`.

Start a new SSH session on the new port.

Delete the old firewall rule for the old port by executing `ufw delete allow 22/tcp`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lodestone-technologies.gitbook.io/knowledgebase/dedicated-hosting/change-default-ssh-port.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
