Key based authentication in SSH is called public key authentication. The purpose of ssh-copy-id
is to make setting up public key authentication easier.
Assuming:
- OpenSSH in both client and server is installed accordingly.
- Both computer/host using popular GNU/linux distribution which OpenSSH enabled by default.
- C is known as Client or user's computer/host.
- R is known as Remote or remote server/computer/host.
Open the terminal and follow this process:
- C: Generate public key:
ssh-keygen -t rsa
- R: If not exist, make a
.ssh
folder on host'shome
folder:mkdir -p .ssh
- C: Use either one of this:
or (recommended)
cat .ssh/id_rsa.pub |ssh [email protected] 'cat>> .ssh/authorized_keys'
ssh-copy-id [email protected]
- C: Now, login to remote computer, it should be not asking password now: