-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path04.txt
More file actions
84 lines (69 loc) · 2.82 KB
/
04.txt
File metadata and controls
84 lines (69 loc) · 2.82 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
04- Aditional capabilities.
---------------------------
04.1 SCPing
-----------
ssh supports a replacement for ftp called scp.
It is much safer and uses a single tcp port 22
eg:
Now that we have a key with passphrase in our agent we can simply:
sjmuniz@tardis:~/keys$ scp cuil-sparkdev.pdf ssh01:~/
cuil-sparkdev.pdf 100% 129KB 28.3MB/s 00:00
04.2 Tunneling (localforward, remote forward, dynamic)
------------------------------------------------------
ssh is able to create tcp tunnels for use with other protocols.
-----------------------
LocalForward: (ssh -L )
------------------------
Open: https://docs.google.com/drawings/d/1U5SxmUaWfBGyyObwBjv8qbMnR0OG0GYJ5IVpWmX01fg
-------------
Opens a listening socket at A that ends up at the other side B and points to a remote host.
You can use it to connect to anything behind and sshd server.
eg:
I have setup mysql on ssh01, but it is listening on 127.0.0.1
I will create a tunnel in my from my local machine to connect to it:
from tardis:3306 to ssh01 localhost:3306
sjmuniz@tardis:~/keys$ ssh -L 3306:localhost:3306 ssh01
and then connect over it. (user sjmuniz passwd: popo123)
sjmuniz@tardis:~$ mysql -h 127.0.0.1 -u sjmuniz -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 61
Server version: 5.5.5-10.3.22-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ^D
Bye
------------------------
Example 2: NGINX
sjmuniz@tardis:~$ ssh -L localhost:8080:ssh04:80 ssh01
Browse http://localhost:8080 and you will endup seeing ssh04:80
------------------------
Remote Forward (ssh -R )
------------------------
https://docs.google.com/drawings/d/1rLvUC051k-qi_m4Q6xeia5_7w0wYuBYdV2QYSRgQEWI
Forwards a port in the REMOTE host to your localhost.
Eg:
sjmuniz@tardis:~$ ssh -v -R 2200:localhost:22 parked
From some other host:
$ ssh -p 2200 sjmuniz@ec2-54-242-174-64.compute-1.amazonaws.com
------------------------
Dynamic Forward ( ssh -D )
------------------------
https://docs.google.com/drawings/d/14z0V5XFsbomSB1JwoO9Ca3nSHEN62eGIRAHtGYWRHfY
Creates a local socks proxy so you can use any app which soports socks, such as
a browser, to dynamically say where the end of the connection will go.
sjmuniz@tardis:~$ ssh -v -D 22202 parked
Configure browser to use socks tcp/22202
04.3 X11 forwarding.
ssh support tunneling X11 apps over ssh tunnels.
Just
sjmuniz@tardis:~$ ssh -Y parked
ubuntu@parked:~$ xeyes -geometry 320x240
04.4 sshfs
ssh is able to act as a filesystem.
sjmuniz@tardis:~$ sshfs parked:/home/ubuntu parked
sjmuniz@tardis:~$ ls parked/
acme.sh bin parkeddomains