Skip to main content

Command Palette

Search for a command to run...

SSH in Linux.

Updated
2 min read
A
Working as a K8s engineer, learning to upskill in DevOps & Cloud, helping people solve problems that I once struggled with myself. My goal is to grow consistently, document my journey, and contribute to the tech community along the way.

(1) What is SSH ?

  • SSH means "Secure Shell".

  • In simple words, used to connect from Device A => Device B.

  • program for logging into a remote machine and for executing commands on a remote machine.

  • runs on port 22.

(2) Why do we need SSH ?

  • intended to provide secure encrypted communications between two untrusted hosts over an insecure network.

  • In simple words, it means only authorized hosts can connect to the remote server.

(3) SSH Diagram

(4) How to SSH ?

  • Download "Git Bash" in your device [computer / laptop] which you want to connect to a remote server.

  • Access the below URL to download the Git bash in your device.

https://git-scm.com/install/windows

  • Open git bash terminal and run the below command and press enter.

ssh-keygen

You will get this message:

Generating public/private ed25519 key pair.

Enter file in which to save the key (/c/Users/hp/.ssh/id_ed25519):

Just press enter, it will store the keys (public & private) inside your home folder.

  • Once you get the above image shown in above snap, run the following commands:

  • (a) pwd : see your current location

    (b) cd <path_to_your_keys> : to navigate to your keys folder

    (c) ls : to list all the items in current location

    (d) cat <enter_your_public_key_name> : to see what is there inside the key

    (e) ssh-copy-id username@<enter_your_remote_server_ip>: to copy public key from local to remote server.

  • Once the above steps are completed, congrats, you have successfully copied your public keys to your server, which you want to connect to.

  • Now, open a terminal (command prompt / git bash / wezterm) in your device and run the below command.

ssh username@<enter_your_remote_server_ip>

Note:

(a) username: enter your username which you have created while VM creation.

  • After running the above command (eg: ssh user@192.168.1.101), you will be able to login to your server.

For Command prompt users, looks like:

For Git bash users, looks like:

For WezTerm users, looks like:

Congratulations !! You have logged in to your remote server. 😃

67 views