· tutorials · 3 min read
Simplifying SSH for Non Linux Users
Have you been jealous of how some dude just pulls up his black screen window ⬛ and races his keyboard ⌨️ with a bunch of commands and wallah the task is done 🎊 and you have no idea 😕 what went down along the way, well worry no more. Today is your lucky day to understand the SSH commands easily.
Are you a computer 💻 programming enthusiast?
One thing you can be totally clear of in your mind is this: You will end up having to use Linux 🐧 operating system some point in your path and then you will have to ssh into your Linux machine or server eventually.
Let’s start with today’s command ssh
.
SSH (Secure Shell)
SSH (Secure Shell) is a network protocol that allows secure remote access to a computer or server over an unsecured network. It provides encryption and authentication, ensuring that the communication between the client and the server remains secure and protected from eavesdropping or tampering.
Problems Solved by SSH:
- ⛓️ Insecure communication: SSH solves the problem of transmitting data over an unsecured network by encrypting the communication, making it difficult for attackers to intercept or manipulate the data.
- 🦾 Password-based authentication: SSH eliminates the need to enter passwords for every login attempt by using public-key cryptography, making the authentication process more secure and convenient.
- ⚒️ Remote access and management: SSH enables users to remotely access and manage computers or servers, making it an essential tool for system administrators, developers, and anyone who needs to access remote resources securely.
What You Can Do with SSH:
- 🐚 Secure remote shell access: SSH allows users to log in to a remote machine and execute commands securely.
- 📂 File transfer: SSH provides the ability to securely transfer files between local and remote machines using tools like SCP (Secure Copy) or SFTP (Secure File Transfer Protocol).
- ⏯️ Port forwarding: SSH allows you to securely forward network connections from your local machine to a remote machine, enabling access to services running on the remote machine.
- 🖥️ Remote command execution: SSH enables you to execute commands on a remote machine without logging in interactively, making it useful for automation and scripting tasks.
Pre-requisites to follow this tutorial:
Since this tutorial will be having hands on examples, you will need to configure some remote machines first. You can do this be either setting up a linux virtual machine in any cloud provider or setting up a local virtual machine with a static IP address. I will be creating a VM for this tutorial.
How to Use SSH:
- Connect to a Remote Machine:
- Use the following command to connect to a remote machine using SSH:
ssh -p port username@remote_host
Replace username
with your Linux username and remote_host
with the IP address or hostname of the remote machine.
That will be like:
ssh -p 22 ubuntu@10.10.10.10
# input your password
- Generating SSH Keys:
- Generate a new SSH key pair on your local machine:
ssh-keygen -t rsa -b 4096
This command will generate a new RSA key pair with a key length of 4096 bits.
- Configuring SSH:
- Edit the SSH client configuration file:
nano ~/.ssh/config
Add the following lines to the file to define a host and specify the SSH key to use:
Host remote_host
Hostname remote_host
User username
IdentityFile ~/.ssh/id_rsa
- Authorized Keys:
- Copy the public key to the remote machine’s
authorized_keys
file:
ssh-copy-id username@remote_host
This command will prompt you to enter the password for the remote machine. Once authenticated, it will copy the public key to the ~/.ssh/authorized_keys
file on the remote machine.
By following these steps, you can set up SSH, connect to remote machines securely, generate SSH keys, configure SSH, and manage authorized keys. SSH is a powerful tool that provides secure remote access and various functionalities for managing remote resources.