Method 1: Use SSH Key-Based Authentication
The most secure and recommended way is to set up SSH key-based authentication, which doesn't require you to include a password in the command.
1. Generate SSH Key Pair (if you don’t have one already):
ssh-keygen -t rsa -b 4096
Save the key in the default location (~/.ssh/id_rsa
).
2. Copy Public Key to the Remote Machine:
ssh-copy-id username@remote_host -p 22
Replace
username
and remote_host
with your remote machine's username and IP address or hostname.3. Run
rsync
without Password or ssh into another machine without Password:rsync -avz /path/to/source/ username@remote_host:/path/to/destination/
ssh username@remote_host -p 22
4. Change folder permission on destination folder.
sudo chmod -R 777 destination_folder
No comments:
Post a Comment