SFTP through KSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP through KSH
# 1  
Old 10-20-2008
SFTP through KSH

Hi all, I am unable to sftp some files. I see on the internet there are no proper solutions given.

I use couple of different ways.

1) Script1.sh

#!bin/ksh

sftp -v user@server_name <<"ENDOFHERE"
mput test_sftp.txt
bye
ENDOFHERE




It prompts me for password and after i enter it will transfer the files.



But I need to automate with out manaul entering the password. can some one please give their insights to automate this.


I also tried this


1)Script1.sh

#!/bin/ksh

sftp -v -b param_file_test user@server_name


"param_file_test"

pwd
mput test_sftp.txt
quit

Thanks in advance




# 2  
Old 10-20-2008
You need to use ssh keys.
Try your man page for ssh-keygen.
# 3  
Old 10-20-2008
Jim, I am not complete familar with the SFTP process but I see the below log when I debug with -v

(dwprd@prd)[/apps/dw/prd/sh> ksh run_sftp_test.sh
OpenSSH_4.1, OpenSSL 0.9.7e 25 Oct 2004
HP-UX Secure Shell-A.04.00.000, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug1: Connecting to host_name port 22.
debug1: Connection established.
debug1: identity file /<path>/.ssh/id_rsa type 1
debug1: identity file /<path>/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version VShell_2_6_2_417 Vl
debug1: no match: VShell_2_6_2_417 VShell
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client name none
debug1: kex: client->server name none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(111111) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'server_name' is known and matches the DSA host key.
debug1: Found key in /<path>/.ssh/known_hosts:14
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /<path>/.ssh/id_rsa
debug1: Authentications that can continue: password,publickey
debug1: Trying private key: /home/dwprd/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (password,publickey).
Connection closed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

2. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

3. UNIX for Dummies Questions & Answers

For SFTP connection - How to give password in UNIX Script (ksh)

Hi, I am not able to give the password in Unix script for SFTP connection. When I am trying to manully SFTP command for accessing the server , it asking for pwd and I could provide the pwd but I am not getting how to provide the pwd inside the Unix script. sftp -v user@xyz.com. ... (4 Replies)
Discussion started by: Vineeta Nigam
4 Replies

4. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

5. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

6. UNIX for Dummies Questions & Answers

Difference Between executing llike ./myscript.ksh and . ./myscript.ksh

Hi , What is the diffence between executing the script like ./myscript.ksh . ./myscript.ksh I have found 2 difference but could not find the reason 1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies

7. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

8. Shell Programming and Scripting

"<< Unmatched" in ksh script using sftp

Getting "syntax error at line 19: `<<' unmatched" trying to run sftp in a ksh script. ...snip... 13 for each in $HOSTS; 14 do 15 if ; 16 then mkdir /usr/restore/$each 17 fi 18 cd /usr/restore/$each 19 sftp -b - server-1 <<EOF 20 get... (6 Replies)
Discussion started by: michaelak28
6 Replies

9. AIX

SFTP Failed---Request for subsystem 'sftp' failed on channel 0

Hi, While I am trying SFTP my machine to another unix machine , it was working fine till 10 min back. But now i am getting the below error "Request for subsystem 'sftp' failed on channel 0" Could you please someone help me to solve or analyise the root cause... Cheers:b:, Mahiban (0 Replies)
Discussion started by: mahiban
0 Replies

10. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies
Login or Register to Ask a Question