Created
August 2, 2023 22:00
-
-
Save greenido/6758285a2d32fdc2cf9211cd5ca43fe2 to your computer and use it in GitHub Desktop.
A shell script that accesses a server over SSH and copies a specific directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set the variables. | |
server_ip="192.168.1.100" | |
username="user" | |
password="passwd" | |
source_directory="/home/user/my_directory" | |
destination_directory="/opt/my_directory" | |
# Connect to the server. | |
ssh -i ~/.ssh/id_rsa $username@$server_ip | |
# Copy the directory. | |
cp -r $source_directory $destination_directory | |
# Disconnect from the server. | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment