SCP script

Chris Zwilling chris at nukequarters.com
Wed Dec 4 17:23:10 CST 2002


I think that the reason the script doesn't work is because the "Password"
prompt doesn't show up on <STDIN>.... it shows up on the tty via PAM
(<STDERR>?)

What I would do here is set up user-host-key based authentication;
then the password requirement would disappear.  Check to see if you have
a .ssh directory in your home directory.  If so, check to see if you have
*.pub files in there.  Those are your public keys that you can put in an
~/.ssh/authorized_keys file on the server that you are ssh'ing (or
scp'ing) to.

For SSH version 2:
$ cd .ssh
$ cat id_dsa.pub
<open a second window and ssh to target the server>
$ cd .ssh
$ vi authorized_keys2
<paste the key into the file on it's own line>
<save and exit>
$

For SSH version 1:
$ cd .ssh
$ cat id_rsa.pub
<open a second window and ssh to the target server>
$ cd .ssh
$ vi authorized_keys
<paste the key into the file on it's own line>
<save and exit>
$ chmod 700 authorized_keys
$ chmod 600 .

SSH version 1 is picky about file and directory permissions.  It is a good
idea to apply the same permissions to the version 2 files also.

It is important to use 'cat' (not 'more' or 'less') to display the key
because 'cat' will not put in line breaks (where others may break up the
lines when the right edge of the tty is hit...).  Also, it is important to
create/edit the authorized_keys[2] files with an editor that doesn't do
word or line wrap.

Once the files are created, you should be able to 'ssh' to the server
without a password.  The first time you ssh to the server, it may ask you
to verify the server's host key.

[czwillin at solstice czwillin]$ ssh admin
Last login: Tue Dec  3 17:24:33 2002 from 10.XXX.XXX.XXX
Sun Microsystems Inc.   SunOS 5.8       Generic February 2000

NOTICE: For security reasons, please use ssh and/or scp when logging into
        other Sun servers and/or transfering files.

[czwillin at admin czwillin]$ exit
logout
Connection to admin closed.
[czwillin at solstice czwillin]$ scp Sony_4mm_Data.pdf admin:
Sony_4mm_Data.pdf    100% |*****************************|  6223 KB    00:01
[czwillin at solstice czwillin]$

I hope this helps!
:)

> > > send " scp root at server1:/path_to_file /path_to_file_on_server2r"
> > > expect "root at server1's password:"
> > > send "passwordr"
> >
> > I'd change the expect line to just "password:"  Its possible that the name
> > may be resolved and displayed differently under cron since cron may be the
> > owner of that job.
> >
>
>
>
>
>

;--------------------------------;
; The problem with reality is    ;  chris at nukequarters.com
;  that there isn't a coherent   ;  http://www.nukequarters.com
;  soundtrack.			 ;
;--------------------------------;




More information about the Kclug mailing list