Do SSH Efficiently.......
Owner : 🧛🏻♂️ - Mr. Sup3rN0va 06-February-2021
Tags : #ssh (💻), #pentesting (👨🏼💻), #tools (⚒), #cheatsheet (📜)
SSH
efficiently☝️ Back to top ☝️
Pre-requisites
sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get install build-essential linux-headers-`uname -r` -y
sudo apt-get install sshfs -y
pip3 install -U pip paramiko --user --no-warn-script-location
ssh-keygen -t rsa
$HOME/.ssh/
folderpublic-key
on to the remote server so that you can do SSH
without passwordssh-copy-id -i $HOME/.ssh/id_rsa.pub user@10.0.0.1
config
file on your machine in $HOME/.ssh
folder asHost b0x
Hostname 10.0.0.1
User user
Port 22
Compression yes
IdentityFile ~/.ssh/id_rsa
ForwardX11 yes
Protocol 2
StrictHostKeyChecking no
chmod 600 $HOME/.ssh/config
ssh b0x
and you are in without password : EASY EASY 😋☝️ Back to top ☝️
Open the config
created above and add these lines
Host b0x
LocalForward 31337 127.0.0.1:31337
RemoteForward 8000 127.0.0.1:8000
<LocalForward> <LocalIP>:<LocalPort> <RemoteIP>:<RemotePort>
<RemoteForward> <RemoteIP>:<RemotePort> <LocalIP>:<LocalPort>
127.0.0.1
ssh -f -N b0x
SSH
as well as port-forward both, then ssh b0x
ssh -f -N -L 31337:127.0.0.1:31337 <SSH_Server>
-f
: tells to background SSH
-N
: tells not to execute remote command. Only used at the time of port-forwarding-L
: tells that we are trying local port forwardingssh -f -N -R <REMOTE_IP>:<REMOTE_PORT>:<LOCAL_IP>:<LOCAL_PORT> <SSH_SERVER>
ssh -D 8123 -f -C -q -N via_host
-D
: tells that you are trying Dynamic Port Forwarding-f
: tells SSH
to go to background-C
: tells SSH
to compress data before sending-q
: quiet mode enabled-N
: tells not to execute remote command. Only used at the time of port-forwardingconfig
file, add this line : DynamicForward 8080
☝️ Back to top ☝️
</div>
paramiko
and sshfs
SSH
SSH-Mount
: SSH-MountSSH-Umount
: SSH-UmountNOTE: Both the mount points are in
$HOME
directories
☝️ Back to top ☝️
</div>
Host b0x
Hostname 10.0.0.1
User user
Port 22
Compression yes
IdentityFile $HOME/.ssh/id_rsa
ForwardX11 yes
Protocol 2
StrictHostKeyChecking no
LocalForward 31337 127.0.0.1:31337 # ---- Only if necessary
RemoteForward 8000 127.0.0.1:8000 # ---- Only if necessary
DynamicForward 8080 # ---- Only if necessary
NOTE : Please remove everything including and after
# ----