1834149 Members
2366 Online
110064 Solutions
New Discussion

Re: sftp syntax

 
SOLVED
Go to solution
Alex Macdonald
Advisor

sftp syntax

Does anyone know what the format is for sftp if I'm doing a non-interactive connection? I'm having trouble figuring out how to pass in my authentication without entering it interactively.
21 REPLIES 21
Kent Ostby
Honored Contributor

Re: sftp syntax

Alex -- Take a look at this thread. I believe it has the answers you need:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=718445
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Alex Macdonald
Advisor

Re: sftp syntax

Well, it kind of helps, but I am still unable to make it through non-interactively.

When I do a sftp user@hostname >> EOF
and pass in my commands I am still being asked to authenticate.

Any ideas?
TwoProc
Honored Contributor

Re: sftp syntax

I just covered this in a post today (going in production with a solution tomorrow)...
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=842336
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

That's a good solution, however it requires I load at least two additional products up on my server - expect, tcl/tk, not to mention any patches I may need. Also expect doesn't seem to install into /usr/bin, at least I can't find it (neither can which, so its not in the path) and it is very unclear from the install guide how to compile tcl/tk. Am I missing something?
Nicolas_17
Frequent Advisor

Re: sftp syntax

Hi Alex,

I set up something just like that recently. I used key-pair autentication so the script would not stop to prompt for a password. Methods for such a setup vary wether you initiate the transfer from a PC with putty of from a *nix machine. If you want a step-by-step howto, it would help to know how you connect.
Nicolas_17
Frequent Advisor

Re: sftp syntax

oh yeah, i forgot. If you use key-pair auth between the two machines, make sure you set an empty passphrase or you'll be stuck with the same problem...
TwoProc
Honored Contributor
Solution

Re: sftp syntax

Alex, at first I didn't want to add two more programs to my server either. If you didn't get a binary in /usr/local/bin - I had the same problem - which I fixed by downloading the previous version...
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

OK, at least the 5.4.2 version contains the binary. But I'm getting ' /usr/lib/dld.sl: Can't find path for shared library: libpthread.sl ' when I attempt to run 'expect'.

The install doc mentions a configure file that I don't see it and I'm not sure how to get the proper libraries included. Any ideas?
TwoProc
Honored Contributor

Re: sftp syntax

Here's what I did to overcome that:
cd /usr/local/lib

ln -s /lib/libpthread.sl .
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

OK, I linked the file but now I'm getting

'/usr/lib/dld.sl: Unresolved symbol: __udivdi3 (code) from /usr/local/lib/libtcl.sl'

Looks like I need to re-compile tcl? Any idea how to do this?
TwoProc
Honored Contributor

Re: sftp syntax

Sorry Alex,
Didn't get that one. You may have to get the source code depot and recompile the thing... It's there at the depot - but it requires gcc... more stuff to load...
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

OK, gcc is loaded up, how do I re-compile tcl/tk?
TwoProc
Honored Contributor

Re: sftp syntax

You're going to have to dload the code depot's instead of the compiled depot for both tcltk and expect. Inside of each you should find a document probably a README, etc which will ask you to run a "make config" then a make "install" in the parent code directory of each one. See the README for exactly how to do it - it's generally not that hard once you've figured out the magic one or two steps.
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

OK, expect and tcl are loaded up and working properly and I'm using expect. My password contains the shell interpretable character '$'. When I send the password the shell interprets the $ and bombs because it thinks I'm using a variable. How can I protect all the charaters within my password using send?
TwoProc
Honored Contributor

Re: sftp syntax

Try a backslash?
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

yeah, I tried that, no dice. According to the man page expect -ex will do literal translation but it doesn't say anything about send.
TwoProc
Honored Contributor

Re: sftp syntax

How about a cheap way out - can you change the password???
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

well I'd have to ask the remote administrator to do it, which seems a little
weak. I find it hard to believe expect couldn't protect the password string...
TwoProc
Honored Contributor

Re: sftp syntax

In the man pages it seems to support escaped character codes like \001 format... Maybe the ascii code for $ ( I forget what it is - but so I don't have to look it up let's say it is 30 ). So about
send "pass"
send "\030"
send "word\n"
Might send the string "pass$word\n"
We are the people our parents warned us about --Jimmy Buffett
Alex Macdonald
Advisor

Re: sftp syntax

Well it is all over but the shouting. In the race to see which solution would most quickly and efficiently obviate the need to interactively authenticate to a remote server using sftp - the use of ssh public keys is the clear winner. expect required a number of dependencies not normally available on HPUX and, in the end couldn't pass a string containing a strong password character. The ssh public keys work really well, just a matter of creating authorized keys on the remote server and having the right entries in the ssh_config file. Thank you everyone and especially John for all your help, I'm movin' on!
Alex Macdonald
Advisor

Re: sftp syntax

Use ssh public keys!