SSH (Secure Shell) is a protocol that helps us securely access remote computers, basically as Telnet does, but using encryption algorithms that help us keep our connection secure, especially if we want to access computers that perform an important function within a network. organization.
Generally, to access we must provide our username and the address of the computer, so that the SSH server asks us for the access password:
ssh usuario@equiporemoto
From the moment the client initiates the first connection between the remote computer and us, the information is already traveling safely, preventing someone from obtaining our access credentials to said computer, however SSH is a very adaptable protocol that offers us many possibilities.
SCP
The first one is to be able to transfer files between the client and remote computer, without the need to mount an FTP or NFS server, simply using SCP (Secure CoPy) that most SSH servers implement:
scp archivo.tar.gz usuario@equiporemoto:/home/usuario
scp usuario@equiporemoto:/var/log/messages messages.txt
SSH Tunneling
This feature is very useful, since it allows us to send and receive information that is not necessarily shell commands between the client and the remote computer, for example ordinary browsing. If you do not guess what use this can have, think about the following: you need to access a page, but the place where you are has a firewall implemented that blocks precisely that page, therefore, we can tunnel with a remote computer that does not have said blocks and browsing said page through our SSH session:
ssh -D 8888 usuario@equiporemoto
Once connected, our SSH client 'listens' on port 8888 as a proxy server, so that we can configure our browser and all traffic is transmitted through the SSH session
Another example that occurs to me is when, due to some geographical restriction, we cannot access a web service from where we are, when making the tunnel, said web service detects the IP of our remote server as the source, not our client IP. This is somewhat equivalent to VPNs (Virtual Private Network)
Reverse SSH
If for some reason we need to access a computer that is behind a firewall and it does not allow us to redirect SSH traffic to it, we can do a 'reverse SSH', in such a way that that computer connects to another SSH server, at which we can also connect to, in order to access the equipment behind the firewall. An example that comes to mind is when we want to help a friend who has no idea how to configure a redirect on his modem, but we need to access his computer remotely:
Friend -> Modem -> SSH Server <- About Us
The steps to follow are relatively very simple:
Friend
ssh -R 9999:localhost:22 usuario@servidorssh
About Us
ssh usuario@servidorssh
Once inside the SSH server, we can connect with our friend's team using
ssh amigo@localhost -p 9999
As you can see, all the magic lies in the -R parameter, which tells the intermediate server that on port 9999 our friend's computer is listening now as a server.
These are just some possibilities that SSH offers us but I invite you to experiment with some more, for example; we can do unattended scripts using RSA keys, redirect X sessions (graphical mode) to our graphical environment, just to mention a few.