# Change SSH Port

First, Open SSH Configuration File (sshd) :

```
sudo nano /etc/ssh/sshd_config
```

Find the line that reads **#Port 22**. Next, eplace it with **New Port** :<br>

<figure><img src="/files/11qeIYiBVCu0hzAlTIoD" alt=""><figcaption><p>Default SSH Port</p></figcaption></figure>

To:

<figure><img src="/files/x2FdKlKdkzqHTWB5jyxY" alt=""><figcaption><p>New SSH Port</p></figcaption></figure>

Second, Save File Modification Press **Ctrl + O** and **Enter** After Press **Ctrl + X**

Next, restart the SSH service using the following command:

**Debian and Ubuntu**:

```
sudo service ssh restart
```

**Debian and Ubuntu with systemd**:

```
sudo systemctl restart ssh
```

**CentOS and Fedora**

```
sudo service sshd restart
```

**CentOS and Fedora with systems**:

```
sudo systemctl restart sshd
```


---

# Agent Instructions: 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://docs.snghosting.com/linux-server/change-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.
