-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSHPortForwardingGuide.txt
66 lines (50 loc) · 1.45 KB
/
SSHPortForwardingGuide.txt
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
############################
Set up SSH Port Forwarding##
############################
###Client Side
##Forward localhost's "port2" to remote host's "port1"
ssh -i auth.pem -R 0.0.0.0:port1:localhost:port2 xxx@xxx.xxx.xxx
#Example (add "p" option if necessary)
ssh -R 0.0.0.0:8133:localhost:22 out@xxx.xxx.xxx
ssh -i auth.pem -R 0.0.0.0:8133:localhost:80 username@ssh.example.com
autossh -M0 -N -f -p29 -R 0.0.0:8132:localhost:22 username@xxx.xxx.xxx
###Server Side
##Edit sshd_config file under /etc/ssh
nano /etc/ssh/sshd_config
##add "GatewayPorts yes" at the bottom so the remote host will listen on the 0.0.0.0 interface instead of the 127.0.0.1 interface
GatewayPorts yes
#Example
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 2048
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
PermitRootLogin prohibit-password
PasswordAuthentication no
ClientAliveInterval 180
UseDNS no
GatewayPorts yes
###########################