scpHow to use an SSH key when using SCP?
Using an SSH key when using SCP is a secure way to transfer files between two computers. To use an SSH key when using SCP, you need to generate an SSH key pair on the computer you are transferring from and add the public key to the computer you are transferring to.
Example code
# Generate an SSH key pair
ssh-keygen -t rsa
# Copy the public key to the remote computer
scp ~/.ssh/id_rsa.pub user@remote_host:~/.ssh/authorized_keys
The code above will generate an SSH key pair and copy the public key to the remote computer.
Code explanation
ssh-keygen -t rsa
: Generates an SSH key pair with the RSA algorithm.scp ~/.ssh/id_rsa.pub user@remote_host:~/.ssh/authorized_keys
: Copies the public key to the remote computer.
Helpful links
More of Scp
- Running SCP in quiet mode
- How to transfer files recursively using SCP?
- How to overwrite files using SCP?
- How to automatically create destination directory when using SCP?
- Is it possible to SCP files in parallel?
- How to show progress when using SCP?
- How to SCP to multiple hosts?
- How to catch errors when using SCP?
- How to use a different port when using SCP?
See more codes...