netgiv/README.md

164 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2022-01-16 20:36:33 +10:30
# netgiv
2022-01-25 22:50:23 +10:30
## What is this?
`netgiv` is a single binary client and server to facilitate sending files across
your local network quickly and easily.
It uses a familiar unix pipeline paradigm, so files can be moved between machines
as part of a pipeline, obviating the need for dealing with temporary files.
2022-01-25 23:16:54 +10:30
`netgiv` automatically detects "copy" (stdin is a pipe) or "paste" (stdout is a
pipe) modes, allowing intuitive use like:
2022-01-25 22:50:23 +10:30
2022-01-25 23:16:54 +10:30
hostA$ pg_dumpall | netgiv
2022-01-25 22:50:23 +10:30
2022-01-25 23:16:54 +10:30
hostB$ netgiv | psql restoredb
2022-01-25 22:50:23 +10:30
Note that since netgiv uses a persistent server, there is no need to setup both ends
2022-01-25 22:54:11 +10:30
of the pipeline in advance (compared to netcat or similar tools).
2022-01-25 22:50:23 +10:30
2025-04-25 15:55:43 +09:30
This also means that you could "copy" once and "paste" multiple times, on
multiple different machines.
2022-01-25 23:16:54 +10:30
All data is encrypted in flight (though not in the temporary files on the server)
Access to the server is granted by an authentication token (preshared key) of your
2022-01-25 22:50:23 +10:30
choice.
## Install
### Binary release
Grab the appropriate version from https://github.com/tardisx/netgiv/releases, unzip
and place the binary somewhere on your $PATH.
### Compiling from source
go install github.com/tardisx/netgiv@latest
`netgiv` should end up on your go binary path.
### Compiling from source
Clone this repository, run `go build`.
## Configuration
2022-01-25 23:16:54 +10:30
Configuration of `netgiv` is via a YAML configuration file in
`$HOME/.netgiv/config.yaml`.
2022-01-25 22:50:23 +10:30
2022-01-25 23:16:54 +10:30
Run `netgiv --help-config` to see a sample config file.
2022-01-25 22:50:23 +10:30
The server requires the 'authtoken' and 'port' configuration keys to be set.
The client requires the 'authtoken', 'port' and 'address' configuration keys to be
set.
* `authtoken` - this is any arbitrary string, you should choose something not easy to
2022-01-25 23:16:54 +10:30
guess
2022-01-25 22:50:23 +10:30
* `port` - this is the TCP port the server will listen on (and that the client will
connect to)
* `address` - the IP address or hostname of the `netgiv` server
## Running
### Server
2022-01-25 22:50:23 +10:30
To run a server, just run:
netgiv --server
`netgiv` will run in the foreground and log accesses to it.
### Client
#### Copy
2022-01-25 22:50:23 +10:30
On any client, run:
2022-01-25 22:59:25 +10:30
$ echo "Hello" | netgiv
2022-01-25 22:50:23 +10:30
To check for success, try:
2022-01-25 22:59:25 +10:30
$ netgiv | cat
2022-01-25 22:50:23 +10:30
You should see "hello" echoed on your terminal.
#### List
2022-01-25 22:50:23 +10:30
To check the list of files on the server:
2022-01-25 22:59:25 +10:30
$ netgiv -l
1: UTF-8 text (6 B)
2: application/x-mach-binary (6.5 MB)
3: video/quicktime (14 MB)
4: image/png (1.5 MB)
Note that netgiv tries to identify each file based on file magic heuristics.
2022-01-25 22:50:23 +10:30
#### Paste
2022-01-25 22:54:11 +10:30
If you would like to fetch (paste) a particular file:
2022-01-25 22:59:25 +10:30
netgiv -p 3 > file.mov
2022-01-25 22:54:11 +10:30
2022-01-25 23:25:04 +10:30
Where '3' comes from the information provided in the `-l` output.
2022-01-25 22:54:11 +10:30
2022-01-25 23:16:54 +10:30
Note that providing no `-p` option is the same as `-p X` where X is the highest
numbered upload (most recent).
2022-01-25 22:54:11 +10:30
#### Burn
If you would like to remove/delete (burn) a particular file:
netgiv -b 3
Where '3' comes from the information provided in the `-l` output.
2022-01-25 22:59:25 +10:30
### Notes on output
Since netgiv is designed to be used in a pipeline, it does not provide any
output on successful execution (apart from your actual data on stdout of course!)
If you'd like to see debugging information, use the `--debug` flag.
Note that `netgiv` will send error logs to stderr in cases of problems.
2022-01-25 22:50:23 +10:30
### Alternative ways of providing the authtoken
It's possible that you do not trust the hosts you are running the `netgiv` client on,
or otherwise not want to store your authtoken in a file on there. If that is the case
there are a couple of alternate options:
#### ENV var
2022-01-25 23:16:54 +10:30
The environment variable NETGIV_AUTHTOKEN can be used to provide the authtoken. A
common way to leverage this is to send it when you ssh to a remote host via the
`SendEnv` option (see your ssh_config man page).
2022-01-25 22:50:23 +10:30
#### Interactive
If the authtoken has not been set by any of the above methods, it will be prompted
2022-01-25 23:26:52 +10:30
for interactively (it will not be echoed to the screen). Note that this only applies
to the client - the server must have a config file with an authtoken specified.
2022-01-25 22:50:23 +10:30
# Other notes
## Temporary file storage
The `netgiv` server will store files in your normal system temporary dir. These files
are *not* encrypted. They will be deleted when the server shuts down (SIGTERM). If you
want or need to remove the files before the server shuts down, you can use the
[burn](#burn) flag.
2022-01-25 22:50:23 +10:30
## Window support
Windows support is marginal, at best, mostly because of the lack of POSIX style
pipes. Bug reports and suggestions for workarounds are welcome.
2022-01-25 23:00:09 +10:30
# Acknowledgements
2022-01-25 23:16:54 +10:30
* thanks to tengig for the name
2025-04-26 12:02:16 +09:30
* thanks to [@jsnfwlr](https://github.com/jsnfwlr) for the burn feature