Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 26, 2022 04:15 pm GMT

SSH (Secure Shel)

A. What Is SSH?
Secure Shell (SSH) is an adminnistrative protocol that allows users to access and modify various settings and files on the server that can run command bassed on the command line interface (CLI).

B. How SSH Works
The way the SSH protocol works is by implementing a client-server model. The connection that occurs is the SSH client (the computer used by the user) connects to the SSH server (the destination remote server).The SSH process starts from the client that connects and uses the key (SSH Key) to verify the SSH server. To implement the SSH protocol can use the command "ssh username@server_address"
Image descriptionSSH client and SSH server can connect using the same key, as long as the key used by the SSH client is not the same as the SSH server, the connection will never be able to connect.
Image descriptionWhen client enters password which is not the same as SSH server then permission is denied then try asking for correct password again to be able to connect with server.

C. Identifying Remote Users
To show which user is logged in using ssh can use the w command.
Image description

D. SSH Host Keys
When using SSH protocol There are 2 types of SSH Key. The first is the Public Key stored on the SSH server and the second is the Private Key stored on the SSH client.

1. Generating SSH Keys
To create a private key and matching public key for authentication, use the ssh-keygen command. Image descriptionNotes :
The public key is stored in /home/user/.ssh/id_rsa.pub
The private key is stored in /home/user/.ssh/id_rsa
2. SSH Public Key Tutorial

ssh-keygen

When prompted for information on where to save the SSH file, just press ENTER on the keyboard.Open the public key with the cat command.

cat /home/user/.ssh/id_rsa.pub

Copy the contents of id_rsa.pub to the user and follow the destination server.

ssh-copy-id user@server_address

While running the above command, you will be prompted for the password for the user. Then try logging in again, and you can log in to the server without needing to enter a password.

ssh user@server_address

3. SSH Private Key Tutorial

ssh-keygen -f  ~/.ssh/encrypted_rsaor can use commandssh-keygen -f .ssh/key-with-pass

The -f option with the ssh-keygen command determines the files where the keys are saved. In the preceding example, the private and public keys are saved in the /home/user/.ssh/key-with-pass
/home/user/.ssh/key-with-pass.pub files, respectively.
Image descriptionEnter your password in the Enter passphrase (empty for no passphrase): and Enter the same passphrase again:, the password you typed will not appear, if you are finished press ENTER.
Copy the new public key to the server.

ssh-copy-id -i ~/.ssh/encrypted_rsa.pub user@server_addressor can usessh-copy-id -i .ssh/key-with-pass.pub user@server_address

Then try to login

ssh -i ~/.ssh/encrypted_rsa user@server_address

This time you have to enter the password used for encryption encrypted_rsa.

*Private and Public keys will be stored in ~/.ssh, which can be checked with ls -l ~/.ssh

ls -l ~/.ssh

Original Link: https://dev.to/fifin25/ssh-secure-shel-26c

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To