1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,34 @@ |
0 |
+--- |
|
1 |
+layout: post |
|
2 |
+title: "Unix beauty – copy & paste between machines" |
|
3 |
+date: 2014-03-30 23:18 |
|
4 |
+comments: true |
|
5 |
+categories: [server, shell] |
|
6 |
+cover: /images/cover/avatar.png |
|
7 |
+keywords: clipboard, send file, linux, server, remote |
|
8 |
+description: Send data between computers remotely |
|
9 |
+--- |
|
10 |
+ |
|
11 |
+Redirecting standard output and using it to put that output to a file is |
|
12 |
+well-known and easy. Almost that easily any output can be redirected from |
|
13 |
+one machine to another one. Say hello to ```nc``` utility. |
|
14 |
+ |
|
15 |
+```nc``` is part of netcat package which comes in two flavors in most of |
|
16 |
+Linux distributions: ```nc-traditional``` and ```nc-openbsd```. In examples |
|
17 |
+below I use -traditional. |
|
18 |
+ |
|
19 |
+On the first machine start listening on some port: |
|
20 |
+ |
|
21 |
+{% codeblock lang:bash %} |
|
22 |
+$ nc -lp 12345 > ~/file_received |
|
23 |
+{% endcodeblock %} |
|
24 |
+ |
|
25 |
+Then, on another machine run something like this: |
|
26 |
+ |
|
27 |
+{% codeblock lang:bash %} |
|
28 |
+$ cat send_file | nc <hostname> 12345 |
|
29 |
+{% endcodeblock %} |
|
30 |
+ |
|
31 |
+That's all. First machine starts listening on port 12345 and another machine |
|
32 |
+sends stream of data to that port. The communication isn't encrypted so for |
|
33 |
+transmitting sensitive data use ```scp```. |
|
0 | 34 |
\ No newline at end of file |