I'd suggest you use public key authentication instead (generate public/private keypair with ssh-keygen on the client, add the public ( . Ssh/id. Pub by default) key to .
Ssh/authorized_keys on the server—see the man page). Than you can either.
Up vote 2 down vote favorite share g+ share fb share tw.
I need write script for copy remote server files to here automatically on server backend. Something like below: #! /usr/bin/expect -f spawn /usr/local/bin/scpdata.
Sh set timeout 3000 expect "[email protected]'s password:" set timeout 3000 send "xxxx" set timeout 3000 send "exit\r" expect eof scpdata. Sh file #! /bin/bash scp [email protected]:/tmp/11-03-15_03:00:01.tar.
Gz /tmp but this not work, where is problem and how to do it? Please help shell ssh scp link|improve this question edited Mar 22 '11 at 8:44Jan Hudec9,154420 asked Mar 22 '11 at 8:24user670809111.
I'd suggest you use public key authentication instead (generate public/private keypair with ssh-keygen on the client, add the public (.ssh/id. Pub by default) key to . Ssh/authorized_keys on the server—see the man page).
Than you can either: Give the passphrase for the key in advance using ssh-agent, or use a key without passphrase. In the later case I suggest you limit the key to a particular command. I am not sure how to set a command for scp, but ssh [email protected] 'cat /tmp/11-03-15_03:00:01.tar.
Gz' > /tmp/11-03-15_03:00:01.tar. Gz is equivalent. You just write command="the command" in front of your key in .
Ssh/authorized_keys. Than the ssh server, when authorized with this key, will always run specified command no matter what was given on ssh command line. This limits the damage an attacker could do if they got access to your passphrase-less key.
If you need the name of file to get to vary, you will need to write a script on the server side, that will pull out the name of $SSH_ORIGINAL_COMMAND (that's where the server-side script gets whatever was given on ssh command-line), check that it's one of the permitted files and cat it.
Yes, it could be use ssh-keygen, but sometime can't change anything in server, that would still be problem. – user670809 Mar 22 '11 at 8:56 @user670809: You only need to put the key in a file in home directory of the user you log in as, which is possible when you have simple ssh access. Any more advanced configurations where that would not be possible will probably be done by competent system administrator who knows (or at least will understand) why use and how to set up ssh public key authentication.
– Jan Hudec Mar 22 '11 at 12:27 thans, Jan. You are right, – user670809 Mar 24 '11 at 1:30.
You never "hit enter" when you send the password: send "xxxx\r" set timeout 3000 does not actually pause -- it sets the timeout value to 3000 seconds (50 minutes). If you need to pause, sleep 3. If your expect patterns are correct, you almost never need to explicitly sleep.
Use exp_internal 1 to debug your patterns. Set up ssh keys and you don't need the expect script at all.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.