Reputation: 1939
I have about 10 file on my local file system that need to be periodically copied to another server at specific locations.
Normally I would do something like:
scp myfile1.txt [email protected]:/path/on/server/for/myfile1.txt
<enter password>
scp randommyfile2.txt [email protected]:different/path/on/server/for/randommyfile2.txt
<enter password>
scp anotherrandmyfile13.txt [email protected]:another/different/path/on/remote/server/for/anotherrandmyfile13.txt
<enter password>
scp myfile4.txt [email protected]:/path/on/server/for/myfile4.txt
<enter password>
I have to do this for all 10 files. I was wondering if I could possibly write a shell script that remembers my username and password so that I don't have to enter the password all the time?
I would also appreciate it if someone could point me in the right direction in using ssh keypairs.
Thanks.
Upvotes: 1
Views: 305
Reputation: 246867
Why aren't you using ssh keypairs?
If the destination paths are the same, then
scp myfile{1..10}.txt [email protected]:/path/on/server/for/
I could devise an expect solution so you only have to enter the password once, but that's a far from optimal answer.
Upvotes: 1