[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: scp and scripts?

On Wed, Jul 06, 2005 at 03:44:13PM -0400, linux starved wrote:
> information.  The following is basically what I want the script to do,
> but I heard scp will not work with authentication.  I also read about
> rsync and tried to get the following one liner to work on the source
> server

To get scp working without prompting you for a password, do
as follows:

(Supposing that you're scp'ing files from machine A to
machine B, and that your username is the same on both A and

1) run 'ssh-keygen -t dsa' on machine A. This will generate
an SSH key of the appropriate type. It will ask you if you
want a passphrase; press enter to use a blank passphrase.
Accept any other defaults presented to you.

2) You will now have a directory ~/.ssh . In there will be
two files (at least): id_dsa and id_dsa.pub. The latter is a
public key, the former a private key.

3) Copy id_dsa.pub to machine B. To do so, type

scp ~/.ssh/id_dsa.pub [machine B's name]:

Note the trailing ':'.

4) Connect to machine B:

ssh [machine B's name]

5) Put the contents of the public key (id_dsa.pub) in
~/.ssh/authorized_keys on machine B:

cat ~/id_dsa.pub >> ~/.ssh/authorized_keys

Note that ~/.ssh may not exist yet on machine B. If it
doesn't, you'll get an error from that last command, and
you'll need to create a new directory --

mkdir ~/.ssh

-- first.

Stephen R. Laniel
+(617) 308-5571
PGP key: http://laniels.org/slaniel.key

Attachment: signature.asc
Description: Digital signature

Reply to: