If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Secure Shell FTP (SFTP?)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-01-04, 15:34
everpro everpro is offline
Registered User
 
Join Date: May 2004
Posts: 12
Secure Shell FTP (SFTP?)

Hi all,

We are new using Secure Shell to connect to our AIX boxes. Currently FTP is till enabled but in the near future it will be disabled and all FTP transcactions must be done via SFTP (Secure FTP). Does anyone know how this works from the command line? I tried the same format as FTP (ie sftp <boxname>) but it doesn't work.

Thanks!

Last edited by everpro; 07-01-04 at 14:40. Reason: typos
Reply With Quote
  #2 (permalink)  
Old 06-02-04, 10:11
skd skd is offline
Registered User
 
Join Date: Sep 2003
Posts: 71
If you server is configured for SSH then you need to create KEYS (public and private) for each machine between which FTP is required.
do man ssh-keygen

for additional details, see openssh.org.

HTH
Reply With Quote
  #3 (permalink)  
Old 06-30-04, 15:14
everpro everpro is offline
Registered User
 
Join Date: May 2004
Posts: 12
Thanks for the info.... have created the keys but (r/o)

I run the sftp command in a script is appears to run without error but the actual file is not ftp'd.... any ideas what would be causing that?

Thanks in advance!!
Reply With Quote
  #4 (permalink)  
Old 07-01-04, 09:28
skd skd is offline
Registered User
 
Join Date: Sep 2003
Posts: 71
try changing permisssion 755 for your home directory at remote machine.

If not then try running ftp from command prompt instead from script and post the results
Reply With Quote
  #5 (permalink)  
Old 07-01-04, 09:54
iaguigon iaguigon is offline
Registered User
 
Join Date: May 2004
Location: Barcelona, Spain
Posts: 54
try including -v option to sftp.
this should write to standard output information on connection, authentication or configuration issues.

hope this helps
Reply With Quote
  #6 (permalink)  
Old 07-01-04, 14:35
everpro everpro is offline
Registered User
 
Join Date: May 2004
Posts: 12
Got it to work but but not exaltly how I'd like it to run... another ?

First thanks for the tips! I verified the permissions on the target directory are set appropriately. I started from scratch and have gotten it to work, however, I had to create two separate files to make this work. Ie.

sendfile.sh contains:

sftp -B up.txt

up.txt contains:

open psadmin@psbhvt2b
ascii
cd sshtest
put mj.txt
quit


Is there any way of getting this to run using only one script? Everytime I try to run the following it does not work:

/apps/ssh2/bin/sftp2 psadmin@psbhvt2b << marker
ascii
cd /home/psadmin
put mj
bye
marker


Here is the verbose output:

sshftp
SshFileCopy/sshfilecopy.c:673: Making local connection.
SshFileXferClient/sshfilexferc.c:1317: ext_name `newline@vandyke.com', data:
00000000: 0a .
SshFileCopy/sshfilecopy.c:616: Connection to local, ready to serve requests.
Sftp2/sftp2.c:412: Connection ready.
SshReadLine/sshreadline.c:2420: Initializing ReadLine...
SshFileCopy/sshfilecopy.c:687: Connecting to remote host. (host = psadmin@psbhvt2b, user = NULL, port = NULL)
Sftp2/sftp2.c:3364: Couldn't find ssh2 on path specified (/usr/local/bin/ssh2). Trying default PATH...
argv[0] = ssh2
argv[1] = -v
argv[2] = -x
argv[3] = -a
argv[4] = -opasswordprompt=%U@%H's password:
argv[5] = -oauthenticationnotify=yes
argv[6] = psadmin@psbhvt2b
argv[7] = -s
argv[8] = sftp
SshSigChld/sigchld.c:238: Registering handler for pid 59104.
SshSigChld/sigchld.c:238: Registering handler for pid 59104.
debug: SshConfig/sshconfig.c:3072: Metaconfig parsing stopped at line 3.
debug: SshConfig/sshconfig.c:3364: Read 3 params from config file.
debug: Ssh2/ssh2.c:1751: Found user config file '/home/psadmin/.ssh2/ssh2_config'
debug: SshConfig/sshconfig.c:3364: Read 1 params from config file.
debug: Connecting to psbhvt2b, port 22... (SOCKS not used)
debug: Ssh2Transport/trcommon.c:3748: My version: SSH-1.99-3.2.9 F-SECURE SSH 3.2.3
debug: client supports 2 auth methods: 'publickey,password'
debug: Ssh2Common/sshcommon.c:588: local ip = 161.128.143.12, local port = 34599
debug: Ssh2Common/sshcommon.c:590: remote ip = 161.128.143.13, remote port = 22
debug: SshConnection/sshconn.c:1945: Wrapping...
debug: Ssh2/ssh2.c:1002: Opening /dev/tty for queries.
debug: SshReadLine/sshreadline.c:2420: Initializing ReadLine...
debug: Remote version: SSH-2.0-3.2.9 F-SECURE SSH 3.2.3
debug: Major: 3 Minor: 2 Revision: 9
debug: Ssh2Transport/trcommon.c:1377: lang s to c: `', lang c to s: `'
debug: Ssh2Transport/trcommon.c:1443: c_to_s: cipher aes128-cbc, mac hmac-sha1, compression none
debug: Ssh2Transport/trcommon.c:1446: s_to_c: cipher aes128-cbc, mac hmac-sha1, compression none
debug: Remote host key found from database.
debug: Ssh2Common/sshcommon.c:380: Received SSH_CROSS_STARTUP packet from connection protocol.
debug: Ssh2Common/sshcommon.c:430: Received SSH_CROSS_ALGORITHMS packet from connection protocol.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
N O T I C E - P R O P R I E T A R Y S Y S T E M

This system is intended to be used solely by authorized
users in the course of legitimate corporate business.
Users are monitored to the extent necessary to properly
administer the system, to identify unauthorized users
or users operating beyond their proper authority, and
to investigate improper access or use. By accessing
this system, you are consenting to this monitoring.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

debug: server offers auth methods 'publickey,password'.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1794: Starting pubkey auth...
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1751: Agent is not running.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1549: Got 0 keys from the agent.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1666: adding keyfile "/home/psadmin/.ssh2/id_dsa_2048_a" to candidates
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1529: Trying 1 key candidates.
debug: Constructing and sending signature in publickey authentication.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:836: reading private key /home/psadmin/.ssh2/id_dsa_2048_a
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1890: Public key authentication was successful.
debug: Ssh2Common/sshcommon.c:340: Received SSH_CROSS_AUTHENTICATED packet from connection protocol.
debug: SshReadLine/sshreadline.c:2478: Uninitializing ReadLine...
debug: Ssh2/ssh2.c:765: Returning user input stream to original values.
debug: Ssh2Common/sshcommon.c:915: num_channels now 1
Sftp2/sftp2.c:3295: buffer: 'AUTHENTICATED YES
'
debug: SshTtyFlags/sshttyflags.c:354: Not a tty. (fd = 0)
debug: Ssh2ChannelSession/sshchsession.c:3161: Requesting subsystem sftp
SshFileXferClient/sshfilexferc.c:1317: ext_name `newline@vandyke.com', data:
00000000: 0a .
SshFileCopy/sshfilecopy.c:616: Connection to remote host 'psadmin@psbhvt2b', ready to serve requests.
sftp>
ssh_pipe_stream_destroy
SshReadLine/sshreadline.c:2478: Uninitializing ReadLine...
debug: SshConnection/sshconn.c:406: EOF from channel stream
debug: Ssh2ChannelSession/sshchsession.c:2249: received exit status : 0
psadmin@psfsta ==> debug: Ssh2Common/sshcommon.c:881: num_channels now 0
debug: Got session close with exit_status=0
debug: Ssh2Common/sshcommon.c:713: Destroying SshCommon object.
debug: SshConnection/sshconn.c:1997: Destroying SshConn object.


The error I hightlighted in red above does not appear be causing the problem since I am using the same ssh/sftp command in the first set of scripts.

Any help would be greatly appreciated!!!

Everpro
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On