Useful Commands/Security: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 20: | Line 20: | ||
| Indirect incoming || | | Indirect incoming || | ||
<source lang="bash"> | <source lang="bash"> | ||
# [Share | # [Share DNS service] | ||
# Listen server: | # Listen server:10053 -> server:22 | ||
# -> localhost: | # -> localhost:53 | ||
ssh -NCfR | ssh -NCfR 10053:localhost:53 server | ||
</source> | </source> | ||
|- | |- | ||
Revision as of 05:39, 21 February 2019
| 情境 | 指令 |
|---|---|
| Indirect Outgoing |
# [Private]
# localhost -> localhost:8888
# -> server:22
# -> somewhere.com:80
ssh -NCfL 127.0.0.1:8888:somewhere.com:80 server
# [Shared]
# any -> *:8888
# -> server:22
# -> somewhere.com:80
ssh -NCfL *:8888:somewhere.com:80 server
|
| Indirect incoming |
# [Share DNS service]
# Listen server:10053 -> server:22
# -> localhost:53
ssh -NCfR 10053:localhost:53 server
|
| SOCKS Relay Proxy |
# [Private]
# localhost -> localhost:3128
# -> server:22
# -> *:*
ssh -NCfD localhost:3128 server
# [Shared]
# any -> *:3128
# -> server:22
# -> *:*
ssh -NCfD *:3128 server
|
| List tunnels |
# List full commands.
ps ax | awk '/ssh \-NCf/ { print $0 }'
# List settings.
ps ax | awk '/ssh \-NCf/ { print $7 }'
# List pids.
ps ax | awk '/ssh \-NCf/ { print $1 }'
# Kill all tunnels.
kill $(ps ax | awk '/ssh \-NCf/ { print $1 }')
|
| Generate key pair |
# Save as default name id_rsa, id_rsa.pub
ssh-keygen
# Save as thefuck, thefuck.pub without password
ssh-keygen -f abc -N ''
# Save as thefuck, thefuck.pub with password
ssh-keygen -f abc -N '12345'
|
| Generate public key from private key |
# Dump
ssh-keygen -yf thefuck.pem
# Save as file
ssh-keygen -yf thefuck.pem > thefuck.pub
# Save as authorized_keys (while ~/.ssh/authorized_keys didn't exist)
ssh-keygen -yf thefuck.pem > authorized_keys
# Append into authorized_keys
ssh-keygen -yf thefuck.pem >> authorized_keys
|