> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/lat-mov/lateral-tool-transfer/transfers-with-ssh.md).

# Transfers with SSH

## Download file(s) with SCP

Retrieve files from a SSH-server running on a non-standard port

```bash
scp -P 2222 offsec@192.168.50.151:/home/offsec/.bash_history offsecHistory.txt
```

<details>

<summary>Example run</summary>

```bash
kali@kali:~$ scp -P 2222 offsec@192.168.50.151:/home/offsec/.bash_history offsecHistory.txt
offsec@192.168.50.151's password: 
.bash_history  100%   4865    31.1KB/s   00:00
```

</details>

## Start an SSH server

If an SSH-server is already installed on the machine you can start it with

```bash
cat /etc/ssh/sshd_config            # check the config
sudo systemctl start ssh
```

When you are done use

```bash
sudo systemctl stop ssh
```

to stop the server.

## Usage information

<details>

<summary>scp -h</summary>

```bash
┌──(kali㉿kali)-[~]
└─$ scp -h    
scp: unknown option -- h
usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]
           [-i identity_file] [-J destination] [-l limit] [-o ssh_option]
           [-P port] [-S program] [-X sftp_option] source ... target

```

</details>

## References

scp - Linux manual page: <https://man7.org/linux/man-pages/man1/scp.1.html>

Secure Shell - Wikipedia: <https://en.wikipedia.org/wiki/Secure_Shell>
