From b2e092238a90af5953bdc69da65ed187f3b75907 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Mon, 5 Aug 2024 01:56:26 -0600 Subject: [PATCH] Add Scripts/Bash/Transfer Files with Netcat.md --- Scripts/Bash/Transfer Files with Netcat.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Scripts/Bash/Transfer Files with Netcat.md diff --git a/Scripts/Bash/Transfer Files with Netcat.md b/Scripts/Bash/Transfer Files with Netcat.md new file mode 100644 index 0000000..8f6cd38 --- /dev/null +++ b/Scripts/Bash/Transfer Files with Netcat.md @@ -0,0 +1,16 @@ +**Purpose**: You may find that you need to transfer a file, such as a public SSH key, or some other kind of file between two devices. In this scenario, we assume both devices have the `netcat` command available to them. By putting a network listener on the device recieving the file, then sending the file to that device's IP and port, you can successfully transfer data between computers without needing to set up SSH, FTP, or anything else to establish initial trust between the devices. + +### Destination Computer +Run the following command on the computer that will be recieving the file. +``` sh +netcat -l > /tmp/OUTPUT-AS-FILE.txt +``` + +### Source Computer +Run the following command on the computer that will be sending the file to the destination computer. +``` sh +cat INPUT-DATA.txt | netcat -q 0 +``` + +!!! info + The `-q 0` command argument causes the netcat connection to close itself automatically when the transfer is complete. \ No newline at end of file