Why use a key-based system?
Using a key-based system makes it much faster, and even more secure to ssh into a server, and scp files onto a remote server. To do this is pretty easy...
- On your local machine, create a .ssh in the home directory (if you don't have one already).
- Go inside the folder.
- Run the ssh-keygen command. This will create a set of public and private keys.
ssh-keygenWhen asked for the name, you can name it whatever you like. For example, I could name one michael_theirwinfamily_net for me to use on this site. When asked for the passphrases, feel free to leave them blank.
- Copy your public key to the server. Use the following command (replace the name of the public key with your real filename, and the host name with your real host)
ssh-copy-id -i [path to .pub file] [remote-host] ssh-copy-id -i ~/.ssh/michael_theirwinfamily_net.pub michael.theirwinfamily.netYou will need to enter your password to log in to the server, after which your key will be added!
- Now, ssh to your server, and you shouldn't need to enter your password!
- If you wish, you can use the same public key for various domains, hosts, etc.
- Don't forget that if your username is not the same as the one you use on the server, use username@hostname for the [remote-host] part of the ssh-copy-id command. For example:
ssh-copy-id -i ~/.ssh/michael_theirwinfamily_net.pub firstname.lastname@example.org