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 overwrite files using SCP?
- How to use SCP with a password?
- How to run SCP in verbose mode?
- How to transfer files recursively using SCP?
- How to list 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?
See more codes...