connection using ssh

# ssh localhost – connect to localhost
accept keyFingerprint. This is because the key cannot be verified.
# exit – exit from ssh connection
# ssh -p 2022 user@server.com
Key fingerprint is stored into:
# ~/.ssh/known_hosts
If the key fingerprint is wrong, there will be: Add correct host key in …… this is happening because the server has been installed on same IP address and key fingerprint from computer don’t match the key fingerprint from server. In order to restore the error, delete the key fingerprint from client. Identify the line from
# ~/.ssh/known_hosts
and delete it using dd from vim.
On server check the settings from:
# vim /etc/ssh/sshd_config

Create public/private key pair.
# ssh-keygen
The private key /home/user/.ssh/id_rsa will be created. Enter the passphrase in order to use this key.
The public key is created:
/home/user/.ssh/id_rsa.pub.
Copy public key to server:
# ssh-copy-id localhost
Use the password for remote user.
In order to copy to a remote host:
# ssh-copy-id -p 9822 user@domain.com
The option -i is useful when the file.pub is not located and have to manually insert the path to that file.
Test it:
# ssh -p 9822 user@domain.com
scp is for secure copy. Is used for copy files:
# scp -P 9822 /local/filename nameOfServer:/path/to/file
Is using “P” for port and not “p” because “p” is used for preserve the files attributes

test it:
1. Open a console and login as root.
ctrl+alt+F2 and login as root.
ctrl+alt+F1 – return to console.
2. from console login to localhost.
# ssh localhost
3. exit to close the session
# exit
4. create a ssh key pair.
# ssh-keygen > file for private > password (could be none)
5. use the key pair in order to login.
# ssh-copy-id localhost