Putty: Network error : cannot assign requested address

10,271

One option is to specify the port directly with -P <port> (e.g., -P 22), per the docs: https://the.earth.li/~sgtatham/putty/0.74/htmldoc/Chapter5.html#pscp-usage

It seems that the PuTTY UI displays the Port value as 22 by default, even if there is no "Default Settings" session stored in the registry, so it appears to be valid even though it is not. The fix for this is to launch PuTTY, select the "Default Settings" and then click Load/Save.

EDIT: This is a known bug in PuTTY 0.74 (https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/pscp-port-0.html).

Share:
10,271

Related videos on Youtube

Pᴇʜ
Author by

Pᴇʜ

Languages I speak: German, English, C#, SQL, php, js, (s)css, html5, VBA, PostScript, Adobe ExtendScript

Updated on June 04, 2022

Comments

  • Pᴇʜ
    Pᴇʜ about 2 years

    Hello I have written a macro to ssh to a server whose username and password are stored at A1 and B1 respectively. When the the macro gets invoked , putty throws error Network error : cannot assign requested address

    Sub putty()
        Dim un As String, pwd As String, pcmd As String, pline As String
        Dim shellObj As Object, runCmd As Object, sOut As Object  
    
        un = Range("A1").Value
        pwd = Range("B1").Value
        Set shellObj = CreateObject("WScript.Shell")
        pcmd = "C:\Program Files\PuTTY\putty.exe " & un & "@15.xx.xx.xx -pw " & 
        pwd & " who"
        Set runCmd = shellObj.exec(pcmd)
        Set sOut = runCmd.StdOut
    
        While Not sOut.AtEndOfStream
            pline = sOut.ReadLine
            Debug.Print pline
        Wend
    End Sub
    

    Is there any workaround for this.

    • Admin
      Admin over 5 years
      I have put the snippet of the code
    • Pᴇʜ
      Pᴇʜ over 5 years
      What happens if you take the output of Debug.Print pcmd and copy it into your shell and execute it. Does it work or does it throw the same error? • Try to replace your putty part with """C:\Program Files\PuTTY\putty.exe"" " probably the space in Program Files is causing this issue.
    • Admin
      Admin over 5 years
      I got the same error after using this """C:\Program Files\PuTTY\putty.exe"" "
    • Pᴇʜ
      Pᴇʜ over 5 years
      Then answer my first question please.
    • Admin
      Admin over 5 years
      Yaa debug is also giving the same error.
    • Pᴇʜ
      Pᴇʜ over 5 years
      I was not asking if the debug gives an error I was asking if you get the same error when you take the result of Debug.Print pcmd and copy/past that into your shell and excecute it gives the same error in the shell? Can you please be more precise and confirm that?
    • Admin
      Admin over 5 years
      can we chat over gmail or skype ?
    • Admin
      Admin over 5 years
      I executed the code till it takes username from A1 , its working absolutely fine, the problem is from where it takes password from B1, then putty throws the error cannot assign requested address