Easy question - How do I combine scp & ssh? - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: How Do I? (https://www.linux-noob.com/forums/forum-60.html) +--- Thread: Easy question - How do I combine scp & ssh? (/thread-1176.html) |
Easy question - How do I combine scp & ssh? - linoox - 2007-09-11 Hi. I'm a newbie and working on a shell script. Trying to first get one small file from a web server -- wget [/url][url=http://test.com/myfile.xml]http://test.com/myfile.xml Then I need to scp it to the db server. I've set up a single-purpose ssh keys and by running this can connect w/out entering password: ssh -i ~/.ssh/whoisit MyHostName My problems is this: when I run scp myfile.xml MyHostName:/dir1/dir2/myfile.xml, I get prompted for password. If I run the ssh command above, I instantly connect to the db server and cannot scp, because I'm already on the remote machine. So, my question is how do I utilize the ssh keys I've set up with scp. I just want to: 1) wget file 2) activate the ssh key, so I connect to the db server w/out entering password 3) copy the file to db servers /dir1/dir2 4) do some kind of a check if the file made it there allright Thank you, Easy question - How do I combine scp & ssh? - znx - 2007-09-12 Quote:Hi. I'm a newbie and working on a shell script. First off, you want to get Public/Private Key Authentication setup: http://kutzooi.co.uk/howto.php?005 Then you want to do this: [url=<___base_url___>/index.php?showtopic=2848][/url][url=<___base_url___>/index.php?showtopic=2848]https://www.linux-noob.com/forums/index.php?showtopic=2848 (just before it says edit your bashrc) But when you are making/editing the ~/.ssh/config add an extra line into it: Code: Host some Now you should be able to just do: ssh some or scp file some:./filename or doing directories scp -r dir1/ some:./dir1 To do a check that it made it there ok you can send an ssh with ls like this: ssh some ls filename or you could do an md5 check with ssh some md5sum filename Hope that helps |