SSH and Its Uses.

What is SSH?

It's a Secure Shell. It is used to communicate the server by using the key on the command line. The default port is 22.

Difference between SSH and Telnet?

SSH is used to login into the remote server.

Telnet is used to check the server is responding to our request or not.

Syntax: telnet IP 22 → this is the syntax we are giving port number is necessary. Without a port number, we can’t execute it.

Two ways to use the SSH:

1. With key — Login into the user and generate a public key, private key by using ssh-keygen. By using public key we can access the server securely. This login doesn’t ask the password. Because of that we using keys.

Syntax: ssh -i public key username@IP

2. Without key — We are having only the username and password for that server. We can directly access by using passwords.

Syntax: ssh username@ip

List of tools to connect the server by using SSH in both Windows and Linux

  1. Mobaxterm(windows)
  2. Putty (Windows)
  3. Command prompt (Linux)
  4. etc..,

What is a Public key?

SSH public-key authentication to connect to a remote system is a robust, more secure alternative to logging in with an account password or passphrase. SSH public-key authentication relies on asymmetric cryptographic algorithms that generate a pair of separate keys. The public key is generated under a .ssh directory.

User public key location in Linux: /home/user/.ssh/

Root user public key location in Linux: /root/.ssh

What is Private key?

It is possible to specify a passphrase when generating the key which will be used to encrypt the sensitive part of this file. Its created under .ssh/ file. We can copy that private key and stored in /root/.ssh/authorized_keys. After only that user is valid to login into the server by using the public key.

SSH configuration location: /etc/ssh/ssh_config whether we can change ssh port or some ssh setting configuration. We will change in this file path.

How to generate a key

Command: ssh-keygen

Generating public/private RSA key pair.
Enter file in which to save the key (/home/sam/.ssh/id_rsa): →Just press Enter or you can choose your own location to generate the public key.

Created directory ‘/home/sam/.ssh’.
Enter passphrase (empty for no passphrase): → If you want to give a password means just Enter it or otherwise just press Enter

Enter same passphrase again: → You have to Enter the password again if you were given or else no need.

Your identification has been saved in /home/sam/.ssh/id_rsa.
Your public key has been saved in /home/sam/.ssh/
The key fingerprint is:
SHA256:XPdOtoDHrENkMEFegNfxmijE79tyU4NAp2B0CXCJ73E sam@arul-ThinkPad-T410
The key’s randomart image is:
+ — -[RSA 2048] — — +
| .++=B=o. |
| .o=o++o. |
| oo+.o+ o |
| .ooE= B . |
| ..oS.=.= + |
| .o ..oo= . |
| . o. .o |
| .oo. |
| .o.. |
+ — — [SHA256] — — -+

Note: If you need to enable MFA (Multi-Factor Authentication code) means you can install google authenticator. Its an extra security for user login.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.