SFTP in Shell Script with RSA-KEY or password.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP in Shell Script with RSA-KEY or password.
# 1  
Old 01-29-2009
SFTP in Shell Script with RSA-KEY or password.

I am trying to SFTP to a couple sites. One has an RSA-KEY that was sent to me. Currently I am running that manually using WinSCP. I would like to set it up as a CRON process on our Linux host (Sun).

Can I use the rsa-key they sent me in any directory or does it need to be placed in a specific directory? Can someone provide an example of a shell script that authenticates using the key and then "puts" the file on the sFTP host?

My other SFTP host doesn't use keys. I have tried several ways to avoid the password prompt during my shell script. Our system doesn't recognize "spawn" when trying to use a batchfile. Here is an example of what I have now:
<snip>
#!/bin/ksh

CURRENT_DIR=`/usr/bin/pwd`
export CURRENT_DIR
ORACLE_SID=$1 ; export ORACLE_SID
ORAENV_ASK=NO ; export ORAENV_ASK
. /usr/local/bin/oraenv
#
#
sqlplus @szre_export.sql
OUT_DIR=/home/me/AXIO
FILEDATE=`date +%Y%m%d%H%M%S`

chmod 666 $OUT_DIR/szre_extract.txt

chmod 666 $OUT_DIR/szre_extract.txt

umask 026


if [ -s $OUT_DIR/szre_extract.txt ]
then
cp $OUT_DIR/szre_extract.txt szremti_extract${FILEDATE}.txt
chmod 666 szre_extract${FILEDATE}.txt

else

exit 0
fi

#!/usr/local/bin/expect
sftp myname@connect2ftp.theirhost.net << end_here
expect "password:"
send "secretpass\n";
interact
put szre_extract${FILEDATE}.txt
quit
end_here

exit
<snip>

I have tried several variations, and it continues to prompt for the password.

I appreciate any help here!
# 2  
Old 02-02-2009
Check out ckermit. I believe it makes use of native openssh, and hence async keys. C-KERMIT 8.0 UNIX MANUAL PAGE AND TUTORIAL
# 3  
Old 02-10-2009
Part 1: I wrote 2 shell scripts to do the SFTP

The first script created the file I needed from Oracle. Then called the second shell script with a different directory set up to get to the "Expect" files.

I am still not sure what I need to do for part 2.

Thanks.
Alemat
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run sftp in shell script without prompting for password?

Hi, Can anyone tell me how to pass password in a shell script for sftp so that i can run it in background without user entering the password? I used a expect script but it timesout after some time and the process remains incomplete at the end. Can anyone suggest any other idea? Will the... (3 Replies)
Discussion started by: Little
3 Replies

2. Shell Programming and Scripting

Password in sftp NOT with key

I've been trying to get out of this, but my manager wont budge. He wants to sftp files from a server while passing the password in the script. I have said we need to use keys...he said no. I asked if we had expect capability...no. He said "use -b batch file command" I have checked every... (1 Reply)
Discussion started by: MJCreations
1 Replies

3. Shell Programming and Scripting

SFTP password through shell script.

Hi All, I would be happy, if someone help me on this that I have only SFTP ID and Password to transfer some log files from webserver boxes to SFTP server Anyone help me that how to pass the password parameter throough the shell scripts, since i don't have ssh login access on the SFTP... (2 Replies)
Discussion started by: l_gshankar24
2 Replies

4. UNIX for Dummies Questions & Answers

SFTP syntax without specifying private key location (no password)

Hi all, I need to connect using SFTP from Red Hat to Windows. Connection between servers work when I specify location of my private key in the script. However, I want to use syntax without private key location specified. I know this should work, as I found it in older scripts. Scripts were... (0 Replies)
Discussion started by: yavvie
0 Replies

5. Shell Programming and Scripting

Auto Script to Access external Server via SFTP using Password and Key

Hello All, I am stuck! I have access to an external server via SFTP. In order to access the external server I was given a specific port, password, and a ppk. I would to create a script on my server end that can I can setup as a corn job, that will connect to the external server and... (1 Reply)
Discussion started by: kingr008
1 Replies

6. Shell Programming and Scripting

Bash script to create rsa key pair

Hello all, I am setting up a cluster of Mac Pro's which need to be able to talk to a master computer, traffic between the nodes and the master needs to take place without a ssh key. I need a script that will create a security key, save it to the default place, enter the password as no password.... (2 Replies)
Discussion started by: sdl27789
2 Replies

7. Shell Programming and Scripting

sftp shell script - Password read error.

Hi, I have script which does the sftp function. In the script in one place it able to read the password from file and other place files with below error. warning: has much more security than supplying the password in the clear warning: on the command line. Failed to get password: File... (0 Replies)
Discussion started by: vino_hymi
0 Replies

8. AIX

While trying to do ssh without password, rsa key file is created as empty.

Hi i have aix 5.3 operating system, and i am trying to do ssh without passwd, when i tried to create a rsakey, it produces empty file as an output, how can solve that problem? why it is giving empty output file, i tried with different user, situation same,.i have restarted sshd server. .ssh... (2 Replies)
Discussion started by: nibiru78
2 Replies

9. Shell Programming and Scripting

SFTP in a shell script without public/private key

Hi everybody, I need some help on writing a script that is able to remote copy file to one server. I already created this types of scripts, and works ok as long as this server I want to copy from is access through telnet. Here is how I do it: ftp -n xxx.xxx.xxx.xxx << _EOF_ user user_name... (6 Replies)
Discussion started by: Alexis Duarte
6 Replies

10. UNIX and Linux Applications

SSH: Avoiding password prompt with rsa key generation

Hi, I am using a remote storage service for backing up our data - we want to have a script run as part of a cron job which would do the backups from our local Linux machine to the service's Linux machine. I want to use tar and ssh to do this (rather than mounting the disk and using cp) .... (5 Replies)
Discussion started by: same1290
5 Replies
Login or Register to Ask a Question