xp_cmdshell PSCP - "The server''s host key is not cached in the registry"

  • Hi Darren,

    You might already have tried this but other way to tracking error is by doing:

    PRINT @sDosCommand

    before executing the command and see if there are any obvious typos or syntax error in the line and then copy paste the whole printed out line in your cmdshell command.

    Umer

  • Heheh! Great catch. I knew about redirecting Y and xp_cmdshell, just never brought the two together (this is my Reese's Peanut Butter Cup 😉

    Here's what I ended up with:

    master..xp_cmdshell 'echo Y > c:\temp\y.txt & c:\ssis\packages\bin\pscp.exe -l Us3r -pw p@ssw0rd c:\SSIS\Packages\Output\1108.txt remote.server.com:/home/path < c:\temp\y.txt & del c:\temp\y.txt'

  • James Rizzo you rocks!!!

    I just registered to thank you!!!:-D

  • I had same problem and solved it by adding the Hostkey in the Registry Editor in HKEY_CURRENT_USER\Software\SimonTatham\PuTTY

  • akhilesh.aggarwal123 (6/2/2010)


    James Rizzo you rocks!!!

    I just registered to thank you!!!:-D

    That's a cool thing to do.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank you James!!! That was the solution I've been looking for.

  • Just wanted to thank James for this as well. I've been stuck on this issue for a couple of months!

  • James Rizzo (9/6/2007)


    I know this is a very old thread but I have yet to see a solution to this problem if your SQL Server is running as the local system account - so here it is!

    1. Create a text file with the letter Y and a carriage return in it:

    For examle :

    Y

    <blank line>

    2. at the end of pscp command add the following:

    <STRONG><</STRONG> <name_of_your_text_file_created_in_step_1>

    THATS IT !!

    Basically, the less than character '<' will redirect the contents of the text file to the input of the pscp command, answering the prompt automatically for you.

    Hope this is of some help to somebody sometime.

    Thats a real good advice by James!!!! From Russia)

  • That did the trick for me as well using psftp. Just a heads up to anyone who is trying to automate this using psftp you can use the same < followed by the file name to bypass the prompt. My command string looks like this:

    C:\SFTP\psftp.exe 1.1.1.1 -l user -pw password 1 -b C:\SFTP\ESRI.txt -P 22 < C:\SFTP\cache.txt

    cache.txt has in it:

    y

    (return)

    Tried it on my SQL sa account and works like a charm. Thanks for the tip!

    Ivan

Viewing 9 posts - 16 through 23 (of 23 total)

You must be logged in to reply to this topic. Login to reply