Add Key to Server\n\nbash\n#Copypublickeytoserver\nssh-copy-iduser@hostname\n\n#Manualmethod\ncat~/.ssh/id_ed25519.pub|sshuser@host\"mkdir-p~/.ssh&&cat>>~/.ssh/authorized_keys\"\n\n#Nowyoucanloginwithoutpassword!\nsshuser@host\n#
5. Port Forwarding\n\n### Local Port Forwarding\n\nbash\n#Accessremoteserviceonlocalport\nssh-L8080:localhost:80user@host\n\n#Nowlocalhost:8080→remote:80\n\n#Example:Accessremotedatabase\nssh-L5432:localhost:5432user@db-server\npsql-hlocalhost-p5432#ConnectstoremoteDB\n#
Remote Port Forwarding\n\nbash\n#Exposelocalservicetoremote\nssh-R8080:localhost:3000user@host\n\n#Remotecanaccessyourlocal:3000viatheirlocalhost:8080\n#
Dynamic Port Forwarding (SOCKS Proxy)\n\nbash\n#CreateSOCKSproxy\nssh-D8080user@host\n\n#Configurebrowsertouselocalhost:8080asSOCKSproxy\n#Nowalltrafficgoesthroughremoteserver\n#
6. tmux - Persistent Sessions\n\n### Why tmux?\n\n- Keep processes running after disconnect\n- Multiple windows in one SSH session\n- Split panes\n- Attach/detach sessions\n\nbash\n#Install\nsudoaptinstalltmux\n\n#Startsession\ntmux\n\n#Newnamedsession\ntmuxnew-smysession\n\n#Detach:Ctrl+b,thend\n\n#Listsessions\ntmuxls\n\n#Attachtosession\ntmuxattach-tmysession\n#
tmux Key Bindings\n\nPrefix:Ctrl+b (press first, then command)\n\n\nPrefix+cNewwindow\nPrefix+nNextwindow\nPrefix+pPreviouswindow\nPrefix+%Splitvertically\nPrefix+\"Splithorizontally\nPrefix+oSwitchpane\nPrefix+dDetachsession\nPrefix+[Scrollmode(qtoexit)\n#
🎯 Exercises\n\n1. Generate SSH key pair\n2. Set up passwordless SSH\n3. Create SSH config with aliases\n4. Transfer files with rsync\n5. Set up tmux session\n\n## 🎓 Key Takeaways\n\n- Use SSH keys, not passwords\n- Configure ~/.ssh/config\n- rsync > scp for large transfers\n- tmux for persistent sessions\n- Harden SSH for security#