Using ssh to log in to your remote server

ssh is a quick way to log on and access the file system of your server. From the bash shell on WSL, I would use this command.


$ ssh jimmy@redmouse.xyz

The remote server will prompt you for the password. You can skip the password step by installing key-based SSH. ( Note:you will still be able to log on using a password on devices without a key pair).


jimmy@WSLBASH:~$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/jimmy/.ssh/id_rsa):

Enter – accept as default


Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Enter – leave the passphrase as blank


Your identification has been saved in /home/jimmy/.ssh/id_rsa.
Your public key has been saved in /home/jimmy/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:j....lgOkE jimmy@WSLBASH
The key's randomart image is:
+---[RSA 2048]----+
| .=++..+ oE |
...................
| + =|
| = |
+----[SHA256]-----+
jimmy@WSLBASH:~$

Your output should look something like this.
Now you have a private and public key saved in ~/.ssh/
Copy the public key to your server.


ssh-copy-id -i ~/.ssh/id_rsa.pub yourserver.com

Now you should be able to log in using ssh without having to enter a password. No password means you can start using other useful bash commands such as scp and rsync.