SSH Cheat Sheet
Published on 23 Jun 2020
Installation and basic usage
- Install ssh server
sudo apt-get install openssh-server
sudo vi /etc/ssh/sshd_config
sudo /etc/init.d/ssh restart
- Run command on SSH
ssh $__USER__@$__HOST__ command
- check network
netstat -tulpn
- To not to close SSH, edit
/etc/ssh/sshd_config
with:
TCPKeepAlive no
ClientAliveInterval 30
ClientAliveCountMax 100
- SCP with permissions
scp -p -r $__USER__@$__HOST__:$__SRC__ $__TARGET__
- Use a specific key file
scp -i ~/.ssh/superkey -p 87 $__USER__@$__HOST__:$__SRC__ $__TARGET__
- Generate RSA key
ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh __USER__@__REMOTE__ 'cat >> .ssh/authorized_keys'
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
SSH Tunneling
- MySQL tunneling from remote server to your local computar:
ssh -L 3333:localhost:3306 __USER__@__REMOTE__
mysql -u __MYUSER__ -p -P 3333 -h 127.0.0.1
- Allows remote hosts to connect to local port 8080.
ssh -g -L 8080:localhost:80 root@$HOST
Is SSH slow?
- Add the following line to
/etc/ssh/sshd_config
:
UseDNS no
- Still slow? add to
/etc/ssh/ssh_config or ~/.ssh/config
:
GSSAPIAuthentication no
References
all tags
IDE architecture" cli crontab crypto csv database docker editor error exceptions fastapi ffmpeg filename git go history http iteration javascript linux logging me mysql numpy orm pdo pentaho php postgres python random rename rsync rust selenium server solana sql sqlite ssh typescript user w3m wordpress