create SSH key
ssh-keygen -q -b 4096 -f ~/.ssh/id_rsa -N '' -C "${USER}@$(hostname -f)"

Copy public key to server (/home/foo/.ssh/authorized_keys)

show log
tail -f /var/log/auth.log
journalctl _COMM=sshd -f

# configuration
~/.ssh/config: user configuration
/etc/ssh/ssh_config: system-wide client configuration
/etc/ssh/sshd_config: system-wide server configurtion

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@

Host 192.168.0.*
User foo
IdentityFile ~/.ssh/foo.id_rsa
BatchMode yes
EscapeChar none
Compression yes

UserKnownHostsFile /dev/null
StrictHostKeyChecking no

h -o HostKeyAlgorithms=ssh-rsa -o FingerprintHash=md5

scp -i ~/ssh_bkp/ ~/.ssh/
cat ~/ssh_bkp/ | ssh -i ~/ssh_bkp/id_rsa 'cat >> .ssh/authorized_keys'
ssh -i ~/ssh_bkp/id_rsa
cat ssh-keygen --if /tmp/ >> ~/.ssh/authorized_keys

# port forward
sudo ssh -L 80: -p 222 -N -i /home/${USER}/.ssh/id_rsa
ssh -L user@host

# Options
-N do not execute a remote command
-f run in background
-C compression
# test
Host mysql.tunnel
User ssh_username
IdentityFile ~/.ssh/config/id_rsa
LocalForward 3307

User ec2-user
UserKnownHostsFile /dev/null

Host X01 X02 ...
User my_username
Compression yes
Ciphers arcfour,blowfish-cbc
Protocol 2
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
IdentityFile ~/.ssh/YYY/id_rsa

IdentityFile ~/.ssh/config/id_rsa
LocalForward 3307

# SendEnv LANG LC_*
#HostKeyAlgorithms ssh-rsa

# reverse tunnel
ssh -fN -R 2222:localhost:22
# connect back from$ ssh me@localhost -p 2222

# SSH config options
ForwardAgent yes
IdentitiesOnly yes
IdentityFile /home/foo/.ssh/id_rsa

Host *
ForwardAgent yes
SendEnv LANG LC_*
StrictHostKeyChecking no

# add defatult domain
Host *
HostName %h
USER user

Host *
USER user
BatchMode yes

# ssh forwarding to sudo
sudo -E -s

echo "Defaults env_keep+=SSH_AUTH_SOCK" >> /etc/sudoers.d/ssh
service sudo restart

# test if SSH agent is running
env | grep SSH_AGENT_PID

# starts SSH agent
eval $(ssh-agent)

# remote X window with bash login
ssh -X USER@REMOTE_HOST -C /bin/bash -l -c "COMMAND"

# socket forward
ssh -N -D 8080 root@
chromium-browser --proxy-server="socks5://localhost:8080"

?? --proxy-server="https=proxyip:8443;http=proxyip:8080"

Enamble DNS forward in Firefox:
network.proxy.socks_remote_dns: true

# port forward
ssh -N -L 8080: root@

# ssh forward to mailserver
# cat /etc/hosts
sudo ssh -L -L -i /home/foo/.ssh/id_rsa -N

deny SSH user
# /etc/ssh/sshd_config
DenyUsers foo
Match User test
PasswordAuthentication no

Host *
ServerAliveInterval 30

Removes host keys from ~/.ssh/known_hosts by hostname or IP
ssh-keygen -R

Update SSH know hosts
ssh-keyscan -t rsa web{1..5} >> ~/.ssh/known_hosts

Forward webserver over SSH
# on client
#echo "GatewayPorts yes" >> /etc/ssh/sshd_config
echo "GatewayPorts clientspecified" >> /etc/ssh/sshd_config
service ssh restart

# on server
ssh -o StrictHostKeyChecking=no -N -R 80: -R 443:

Get hostkey
ssh-keyscan SERVER

SendEnv no

RemoteForward 80
LocalForward 1521
GatewayPorts no

# double forward
ssh -A -R 10080:forward_from.tld:80 user@forward_to.tld "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -g -N -L 80:localhost:10080 localhost"

# Forward DB port by SSH tunnel and make public accessible
ssh -A -R 10080:localhost:3306 root@db.example.comt "ssh -g -N -L 3306:localhost:10080 localhost"

# copy block device over network with SSH
dd if=/dev/sdc | ssh -C user@host dd of=/dev/sdc
cat file | ssh -e none remote-host 'cat > file'

# show SSH status
systemctl status ssh

sudo ssh \
-i /home/foo/.ssh/id_rsa \
-o PermitLocalCommand=yes \
-o LocalCommand="sudo ifconfig tun0 pointopoint netmask; sudo route add -net gw netmask" \
-o ServerAliveInterval=60 \
-w 0:0 -p 22022 \
'sudo ifconfig tun0 pointopoint netmask; echo tun0 ready'

# sshfs
sshfs -o ServerAliveInterval=15 /mnt