Skip to content

Instantly share code, notes, and snippets.

@mainframed
Created January 23, 2026 12:54
Show Gist options
  • Select an option

  • Save mainframed/0c64b69757a37b3df35f5fd9c9ad3676 to your computer and use it in GitHub Desktop.

Select an option

Save mainframed/0c64b69757a37b3df35f5fd9c9ad3676 to your computer and use it in GitHub Desktop.
getfiles.sh
#!/bin/bash
REMOTE_USER="user"
REMOTE_HOST="hostname"
REMOTE_PASSWORD="password"
LOCAL_DIR="."
while read remote_file; do
# Remove leading slash from the path
local_path="${remote_file#/}"
local_file="$LOCAL_DIR/$local_path"
# Create the local directory structure
mkdir -p "$(dirname "$local_file")"
# Copy the file
sshpass -p "$REMOTE_PASSWORD" ssh "$REMOTE_USER@$REMOTE_HOST" cat "$remote_file" > "$local_file"
echo "Copied: $remote_file"
done < filelist.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment