What is ssh?
SSH is a network protocol by which two machines can communicate with each other, we can transfer information or data from client and server in a secure way.
It uses encryption to secure the data that travel over the network to secure it.
Use of ssh:
We can access a remote machine using ssh over the same network.
Command: ssh <user>@<ip> eg: ssh email@example.com
Now there are two types of authentication methods that we can use :
- Password-based authentication
- Key-based authentication
- In Password-based authentication, we need the password of the host to access it.
- In key-based authentication, we need keys on the machines ie private and public keys.
How to generate keys.
It generates two keys private key(id_rsa) and public key(id_rsa.pub) at ~/.ssh/
- Private is private to our local machine, this should never be shared with others.
- Public key can be shared with other servers/machines. We can copy our public key to a host/server using ssh-copy-id <user>@<ip> or if we can access the UI of the server, we can even upload it there as in GitLab, GitHub.