Re: Bash script - scp password issues



On Mon, 15 Jan 2007 11:26:53 -0800, markrobertstockwell@xxxxxxxxx wrote
this:


I just need the right syntax. I am trying to setup a bash script to copy
everything from one directory to another.

This works:

scp backup@abc-it1:/backup/. .

but the issue is it asks for a password.

This is what I've come up with (it's not working).

Any ideas on what I'm missing?

#!/bin/bash
export userpw=****

scp backup@abc-it1:/backup/. .<<-EOS
user $userpw
quit
EOS


You could try the -B option

but the best method is to create use ssh-keygen to create public keys
without passphrases on each machine. Copy the generated .pub key to the
backup@:~/.ssh folder of each machine as authorized_keys. Then ssh, scp
and rsync -e "ssh " (over ssh) won't ask for passwords or passphrases.

man scp, ssh, ssh-keygen

noi@siam :~> ls -l .ssh
total 20
-rw-r--r-- 1 noi users 402 2006-03-29 23:17 authorized_keys
-rw------- 1 noi users 1655 2005-07-02 18:41 config
-rw------- 1 noi users 1675 2006-08-20 12:44 id_rsa
-rw-r--r-- 1 noi users 408 2006-08-20 12:44 id_rsa.pub
-rw-r--r-- 1 noi users 401 2006-08-19 15:18 known_hosts



.



Relevant Pages

  • Re: Is SSH worth it??
    ... > We would be using SSH and SCP. ... SCP for automated scripts. ... > client will not be prompted for a password. ... remote machine, but imho it is better to swap client+server and give ...
    (Security-Basics)
  • RE: SCP and MVS data sets?
    ... SCP and MVS data sets? ... Is it possible that the open function is different in SCP? ... You can also do the following weirdness to use ssh to copy a z/OS legacy ...
    (bit.listserv.ibm-main)
  • Re: linux to linux scp in batch mode: how?
    ... reason why it works now is because of the dsa key. ... > been configured automatically when I set up ssh, I would imagine that I am ... >> I have ssh and scp up and running on my two Redhat 7.2 Linux machines, ... >> between the machines. ...
    (comp.security.ssh)
  • Re: linux to linux scp in batch mode: how?
    ... And now I can log on via ssh or scp without being prompted for the password. ... I am not specifically using ssh-agent, ... > between the machines. ...
    (comp.security.ssh)
  • RES: Is SSH worth it??
    ... attacker would have root access to another machines in your network. ... When I needed automated scripting using ssh and scp I used this programming ... SCP for automated scripts. ...
    (Security-Basics)