Introduction
SSH (Secure Shell) is a cryptographic network protocol widely used in the industry to securely access servers over an unsecured network. It enables remote login to computer systems, execution of commands on remote machines, file transfer, and tunneling, ensuring secure communication and data integrity.
Keys
SSH uses public-key cryptography to authenticate the remote computer and allow it to authenticate the user, if necessary. The SSH key pair consists of a private key and a public key. The private key is kept secret and should never be shared, while the public key can be shared with anyone.
Generate a new SSH key pair
RSA (default)
ed25519
View public key
Configuration
It is possible to configure the SSH client to use the keys and other settings by editing the ~/.ssh/config
file.
~/.ssh/config
Connect to a remote server
To connect to a remote server using SSH, you need to know the username and the address of the server. The default port for SSH is 22, but it can be changed by the server administrator.
Example
Copy files via SCP
Secure Copy Protocol (SCP) is a command-line utility that allows you to securely copy files and directories between two locations. It uses the SSH protocol to encrypt the data during the transfer, ensuring data integrity and confidentiality.
Find the target file or dir
Find current address
copy the desired path
Copy remotely to local
Copy directory recursivelly
Error Troubleshooting
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Error when you dont add the ssh into the known hosts
Solution
For example,