> For the complete documentation index, see [llms.txt](https://kchuene.gitbook.io/data-communication-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kchuene.gitbook.io/data-communication-project/archive/ssh.md).

# SSH

Configurations for detection and response against potentially malicious traffic.

## Re-Routing

Consider the policy as that only connections from the controller node are allowed to the Production SSH service. With this we want to reroute all non-controller traffic (internal and external) to the **Cowrie SSH** honeypot.&#x20;

**Enable IP Forwarding**

Enable machine to forward/redirect traffic to other hosts in the network

{% code overflow="wrap" lineNumbers="true" %}

```
sysctl net.ipv4.ip_forward
sudo sysctl net.ipv4.ip_forward=1
```

{% endcode %}

**Redirect Non-Local Connection Attempts**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 ! -s 192.168.56.0/24 -j DNAT --to-destination 192.168.56.101:22
```

{% endcode %}

where

* `-t nat` When a packet that creates a new connection is encountered.
* `-A PREROUTING` Alter packet as soon as it comes in.
* `-j DNAT` Alter the destination address of the packet to --to-destination.

also, the `! -s 192.168.56.1/24` option checks for packets not coming from the local network.

Lastly we solve the **Missing Return Path** issue where the **Cowrie** server attempts to send the response directly to the source IP, but the source IP rejects it because it was expecting it from the Production node (the one the source IP attempted to connect to in the first place)

{% code overflow="wrap" lineNumbers="true" %}

```
sudo iptables -t nat -A POSTROUTING -p tcp --dport 22 -d 192.168.56.101 -j MASQUERADE
```

{% endcode %}

where

* `-A POSTROUTING` Alter packet as it is about to go out
* `-j MASQUERADE` specify our IP as the return address.

{% embed url="<https://hackertarget.com/cowrie-honeypot-ubuntu/>" %}

{% embed url="<https://linux.die.net/man/8/iptables>" %}

{% embed url="<https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands>" %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kchuene.gitbook.io/data-communication-project/archive/ssh.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
