24 Nov Useful Linux commands
SSH and SCP
SSH tunneling and Remote SSH port forwarding
A usage case: To make a remote web interface (running on port 80) accessible locally to your browser on port 2000 :
#ssh -f user@server -L 2000:server:80 -N
Then, on your browser, just enter: http://127.0.0.1:2000
SSH Login with Public key setup
login as root
#ssh-keygen -t rsa -b 2048
#ssh-copy-id -i ~/.ssh/id_rsa.pub root@
SCP – Resume copy if abruptly stopped
# scp vm02_disk2.img.qcow2 google@8.8.8.8:/tmp/
The following command resume the above secure copy if abruptly stopped
# rsync –rsh=’ssh’ -av –progress –partial vm02_disk2.img.qcow2 google@8.8.8.8:/tmp/
tar
tar – replace file on tar archive
The following command replace vpn.cnf with a local copy in the archive openvpn.tar
# tar –delete –file=openvpn.tar vpn.cnf; tar –append –file=openvpn.tar vpn.cnf
ls
list size of directories
The following command list the size of directories in the current position
# ls -l | grep ^d | awk ‘{print $9}’ | while read line; do du -hs $line; done
Security
Generate a Random Password
# date | sha256sum
# openssl rand -base64 32