summaryrefslogtreecommitdiff
path: root/doc/note/ssh/ssh-usage.txt
blob: f9bc2a865519382762fb7b893b28a4f9d6accb44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

SSH Usage Examples
==================


## Download Files

Can help when downloading log files:  tar --ignore-failed-read

(TODO this cmd looks broken)

  ssh HOST -- "cd /data/instances/default/logs && tar -cz foo/bar.log*" > ARCH_NAME.tgz


## Upload Files

  tar cz file1 file2 file3 | ssh USER@HOST 'tar -C /dir/on/remote xz'


## Port-Forwarding

Example: When request on "127.0.0.1:1234", then forward that
request to "localhost:7080" on HOST.

  ssh -L 127.0.0.1:1234:localhost:7080 HOST


## Use explicit client port

ssh -o 'ProxyCommand ncat -p12345 %h %p' MY_SERVER


## Run Cmd via jumphost

Source: "https://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/"

### Based on -tt but without tt
ssh MYJMPHOST ssh MYHOST -- echo "\"foo\ \ \ \ bar\"" > out.txt

### "seems" to work. But somehow my binary data through stdio is broken.
ssh -tt MYJMPHOST ssh -tt MYHOST echo foo bar

### This tries to ssh directly to MYHOST (not what I'm searching for)
ssh -o "ProxyJump MYJMPHOST" MYHOST -- echo foo bar