SSH Cheat Sheet
This sheet goes along with this SSH YouTube tutorial
Login via SSH with password (LOCAL SERVER)
ssh brad@192.168.1.29Create folder, file, install Apache (Just messing around)
mkdir testcd testtouch hello.txtsudo apt-get install apache2Generate Keys (Local Machine)
ssh-keygenAdd Key to server in one command
cat ~/.ssh/id_rsa.pub | ssh brad@192.168.1.29 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >>  ~/.ssh/authorized_keysCreate & copy a file to the server using SCP
touch test.txtscp ~/test.txt brad@192.168.1.29:~DIGITAL OCEAN
Create account -> create droplet
Create Keys For Droplet (id_rsa_do)
ssh-keygen -t rsaAdd Key When Creating Droplet
Try logging in
ssh root@doserverIf it doesn't work
ssh-add ~/.ssh/id_rsa_do(or whatever name you used)
Login should now work
ssh root@doserverUpdate packages
sudo apt updatesudo apt upgradeCreate new user with sudo
adduser bradid bradusermod -aG sudo bradid bradLogin as brad
ssh brad@doserverWe need to add the key to brads .ssh on the server, log back in as root
ssh root@doservercd /home/bradmkdir .sshcd .sshtouch authorized_keyssudo nano authorized_keys(paste in the id_rsa_do.pub key, exit and log in as brad)
Disable root password login
sudo nano /etc/ssh/sshd_configSet the following
PermitRootLogin noPasswordAuthentication noReload sshd service
sudo systemctl reload sshdChange owner of /home/brad/* to brad
sudo chown -R brad:brad /home/bradMay need to set permission
chmod 700 /home/brad/.sshInstall Apache and visit ip
sudo apt install apache2 -yGithub
Generate Github Key(On Server)
ssh-keygen -t rsa(id_rsa_github or whatever you want)
Add new key
ssh-add /home/brad/.ssh/id_rsa_githubIf you get a message about auth agent, run this and try again
eval `ssh-agent -s`Clone repo
git clone git@github.com:bradtraversy/react_otka_auth.gitInstall Node
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -sudo apt-get install -y nodejsInstall Dependencies
npm installStart Dev Server and visit ip:3000
npm startBuild Out React App
npm run buildMove static build to web server root
sudo mv -v /home/brad/react_otka_auth/build/* /var/www/htmlBacklinks
Knowledge Base
- [[ssh-cheatsheet]]