psorensen
psorensen

Reputation: 827

SSH SCP files from a list

I have a specific list of files that I need to copy from a remote server. Is this possible with SCP?

I know I can copy individual files using scp {user_name}@{host}:{filepath} . , but is there any way to take a .csv or .txt and run a foreach loop?

Upvotes: 6

Views: 14736

Answers (3)

cotteletta
cotteletta

Reputation: 1

scp `cat /path/to/file` login@remote_host

Upvotes: 0

Jacob Margason
Jacob Margason

Reputation: 622

I found that it was easier to use tar with a list then send the files individually via scp:

tar -czvf archive.tar.gz -T file-list.txt && scp archive.tar.gz user@host:/path/

I use this on systems that don't have rsync available, this way you also avoid iterating password prompts or TCP/SSH connection limits.

Upvotes: 3

Gal Red Jelly Kauffman
Gal Red Jelly Kauffman

Reputation: 157

while read file; do scp "user@host:$file" .; done <  files

Upvotes: 11

Related Questions