SSH: Origins and Introduction
Secure Shell (SSH) was developed by the IETF's Network Working Group. SSH is a security protocol built on top of the application and transport layers, providing a secure transport and working environment for the shell on a computer.
SSH is currently one of the more reliable protocols designed specifically to secure remote login sessions and other network services. Using SSH effectively prevents information leaks during remote administration. SSH encrypts all transmitted data and also helps prevent DNS spoofing and IP spoofing.
Using SSH
My examples mainly use a Mac connecting to an Ubuntu host
1. Connecting to a Remote Host
Regular Users
ssh user@1.2.3.4, press Enter, type your password, and you're logged in to the remote host.
Lazy Users
Typing a password is a hassle, so use an RSA key
Generate a key on your Mac, then view and copy it with these commands
ssh-keygen -t rsa generates the key; just press Enter through the defaultscat ~/.ssh/id_rsa.pub shows the generated key so you can copy it. That's all done locally on the Mac.
Then log in to the VPS, go to the .ssh directory, and paste the key
|
|
Still too much hassle? Is there a way to skip copy and paste? Of course. One command copies the key to the right filessh-copy-id user@1.2.3.4
Ultra-Lazy Users
Nice, no more typing the password every time. But you still have to type ssh user@1.2.3.4. If you can skip the password, you can skip this too. Create a file called test-ssh, put ssh user@1.2.3.4 in it, save and exit, then make it executable with chmod 755 test-ssh. Now just run ./test-ssh to log in to the VPS
2. Run Remote Commands Locally
Run commands on the VPS from your local machine without logging in. For example, to create a filessh user@1.2.3.4 'touch test'
creates the file. If you need root privileges, add the -t flagssh -t user@1.2.3.4 'touch test'
3. Remote Copy
To download file a from the home directory on the VPS to my Downloads folder, use the scp commandscp -r user@1.2.3.4:~/a ~/Downloads
To upload the local file test to the aa directory under the VPS home directory, do the samescp -r ~/test user@1.2.3.4:~/aa
