Depending on the size of the file, you may not want to go through the hassle of transferring it via Netcat, FTP, or some other file transfer method.
In some cases, you can convert a file to Base64 code, and then simply copy/paste the code between the machines.
We’ll do that here. There is a file named viewuser
on our victim box we want to copy to our Kali attacking machine. I already have a SSH connection to the victim box. Let’s start by converting the file to Base64.
base64 -w0 /usr/bin/viewuser
Note: -w0
gets rid of line wrapping.

We’ll highlight the code and then Copy Selection.

With that in our clipboard, head over to your Kali machine and let’s create a file called viewuser.b64
gedit viewuser.b64
Paste the code and Save the file.
Now just run the following command to decode the contents and dump it into a new file.
base64 -d viewuser.b64 > viewuser

That’s it! You’ve successfully transferred the file between machines.