It's impossible to automic log into server using sftp in unix shell script with password authorization like what we can do with ftp below.

ftp -nv <<EOF
open ${FTP_HOST}
user ${FTP_USER}
${FTP_PASSWD}
binary
cd ${FTP_DIR}
put ${FTP_FILE_NAME}
dir
${FTP_FILE_NAME}
quit
EOF          

But we have another solution for this, once it setup, it both conveneint and sercure. see following steps. tested on AIX.

On the client machine, type:

ssh-keygen -t rsa (or dsa, depending on the desired mode)
respond to the questions with CR

Make sure that the ssh daemon is running on the server.

On the client machine, CD to the .ssh directory in your home directory
and type:

scp id_rsa.pub <serverloginid>@<serverhostname>:id_rsa.pub
you will have to enter the password this time

Log onto the server and CD to your home directory. (The "id_rsa.pub"
file should be visible). Check to see if a .ssh directory exists; if
not, create one and type:

cat id_rsa.pub >> .ssh/authorized_keys

You can delete the id_rsa.pub file from the server (or move it into the
.ssh folder).

That should set up the automatic login authentication.

Reference

2006-6-14 Update

If access to the remote system is still denied you should
check the permissions of the following files on it:
  • the home directory itself
  • the ~/.ssh directory
  • the ~/.ssh/authorized_keys file

The permissions should allow writing only by you (the owner). This example shows the most relaxed permissions you could use.

  hrothgar% cd
hrothgar% ls -ld . .ssh .ssh/authorized_keys
drwxr-xr-x 36 kim kim 4096 Jul 25 02:24 .
drwxr-xr-x 2 kim kim 512 Apr 10 02:30 .ssh
-rw-r--r-- 1 kim kim 1674 Apr 10 02:29 .ssh/authorized_keys

Post a comment

mail.png


相似文章|Related Entries

最近更新|Recent Entries

不定期更新|Handy Entries

分类栏目|Categories

按月归档|By Month

2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

站内链接|Site Links

Powered by
Movable Type 3.34