FAQ
I got a piece of code which works with code.google.com/p/gosshold/ssh and
got some problems with refactoring it to the new go.crypto/ssh library.

type SignerContainer struct {
         signers []ssh.Signer
}

func makeKeyring() ssh.ClientAuth {
         signers := []ssh.Signer{}
         keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
os.Getenv("HOME") + "/.ssh/id_dsa"}

         for _, keyname := range keys {
                 signer, err := makeSigner(keyname)
                 if err == nil {
                         signers = append(signers, signer)
                 }
         }

         return ssh.ClientAuthKeyring(&SignerContainer{signers})
}

func main() {
         ...

         config := &ssh.ClientConfig{
                 User: os.Getenv("USER"),
                 Auth: []ssh.ClientAuth{makeKeyring()},
         }


Under new library makeKeyring() looks like this. What should be a proper
return value of makeKeyring()?

func makeKeyring() ssh.AuthMethod {
         signers := []ssh.Signer{}
         keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
os.Getenv("HOME") + "/.ssh/id_dsa"}

         for _, keyname := range keys {
                 signer, err := makeSigner(keyname)
                 if err == nil {
                         signers = append(signers, signer)
                 }
         }

         return // what to put here?
}

func main() {
         ...

         config := &ssh.ClientConfig{
                 User: os.Getenv("USER"),
                 Auth: []ssh.AuthMethod{makeKeyring()},
         }




--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Jonathan Pittman at Jul 21, 2014 at 1:27 am
    http://godoc.org/code.google.com/p/go.crypto/ssh#PublicKeys

    I believe you want:

    return ssh.PublicKeys(signers...)
    On Sunday, July 20, 2014 1:36:41 PM UTC-4, zork wrote:

    I got a piece of code which works with code.google.com/p/gosshold/ssh and
    got some problems with refactoring it to the new go.crypto/ssh library.

    type SignerContainer struct {
    signers []ssh.Signer
    }

    func makeKeyring() ssh.ClientAuth {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return ssh.ClientAuthKeyring(&SignerContainer{signers})
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.ClientAuth{makeKeyring()},
    }


    Under new library makeKeyring() looks like this. What should be a proper
    return value of makeKeyring()?

    func makeKeyring() ssh.AuthMethod {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return // what to put here?
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.AuthMethod{makeKeyring()},
    }



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Zork at Jul 21, 2014 at 7:48 pm

    On Sunday, July 20, 2014 8:27:02 PM UTC-5, Jonathan Pittman wrote:
    http://godoc.org/code.google.com/p/go.crypto/ssh#PublicKeys

    I believe you want:

    return ssh.PublicKeys(signers...)
    return ssh.PublicKeys(signers)

    ./cs.go:59: cannot use signers (type []ssh.Signer) as type ssh.Signer in
    argument to ssh.PublicKeys:
             []ssh.Signer does not implement ssh.Signer (missing PublicKey
    method)

    Any clues?

    On Sunday, July 20, 2014 1:36:41 PM UTC-4, zork wrote:

    I got a piece of code which works with code.google.com/p/gosshold/ssh
    and got some problems with refactoring it to the new go.crypto/ssh library.

    type SignerContainer struct {
    signers []ssh.Signer
    }

    func makeKeyring() ssh.ClientAuth {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return ssh.ClientAuthKeyring(&SignerContainer{signers})
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.ClientAuth{makeKeyring()},
    }


    Under new library makeKeyring() looks like this. What should be a proper
    return value of makeKeyring()?

    func makeKeyring() ssh.AuthMethod {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return // what to put here?
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.AuthMethod{makeKeyring()},
    }



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jonathan Pittman at Jul 21, 2014 at 10:47 pm
    You need to do

    return ssh.PublicKeys(signers...)

    NOT return ssh.PublicKeys(signers)

    The ... expands the signers slice to separate arguments.
    On Monday, July 21, 2014 3:48:52 PM UTC-4, zork wrote:

    On Sunday, July 20, 2014 8:27:02 PM UTC-5, Jonathan Pittman wrote:

    http://godoc.org/code.google.com/p/go.crypto/ssh#PublicKeys

    I believe you want:

    return ssh.PublicKeys(signers...)
    return ssh.PublicKeys(signers)

    ./cs.go:59: cannot use signers (type []ssh.Signer) as type ssh.Signer in
    argument to ssh.PublicKeys:
    []ssh.Signer does not implement ssh.Signer (missing PublicKey
    method)

    Any clues?

    On Sunday, July 20, 2014 1:36:41 PM UTC-4, zork wrote:

    I got a piece of code which works with code.google.com/p/gosshold/ssh
    and got some problems with refactoring it to the new go.crypto/ssh library.

    type SignerContainer struct {
    signers []ssh.Signer
    }

    func makeKeyring() ssh.ClientAuth {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return ssh.ClientAuthKeyring(&SignerContainer{signers})
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.ClientAuth{makeKeyring()},
    }


    Under new library makeKeyring() looks like this. What should be a
    proper return value of makeKeyring()?

    func makeKeyring() ssh.AuthMethod {
    signers := []ssh.Signer{}
    keys := []string{os.Getenv("HOME") + "/.ssh/id_rsa",
    os.Getenv("HOME") + "/.ssh/id_dsa"}

    for _, keyname := range keys {
    signer, err := makeSigner(keyname)
    if err == nil {
    signers = append(signers, signer)
    }
    }

    return // what to put here?
    }

    func main() {
    ...

    config := &ssh.ClientConfig{
    User: os.Getenv("USER"),
    Auth: []ssh.AuthMethod{makeKeyring()},
    }



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Kevin Malachowski at Jul 22, 2014 at 12:13 am
    That's what it seems like, but I think it's important to note that the slice itself is passed through rather than allocating a new memory area and copying it over. If the called function modifies the contents of the slice then the caller will notice this.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jonathan Pittman at Jul 24, 2014 at 4:51 pm
    Sorry if I caused confusion. In my head I tend to visualize it as laying
    out the slice contents to match the layout needs of the function arguments.
      Yes, Kevin is correct. Here is the point in the language spec that
    indicates the behavior.

    http://golang.org/ref/spec#Passing_arguments_to_..._parameters

    @zork, did everything work out?
    On Monday, July 21, 2014 8:13:16 PM UTC-4, Kevin Malachowski wrote:

    That's what it seems like, but I think it's important to note that the
    slice itself is passed through rather than allocating a new memory area and
    copying it over. If the called function modifies the contents of the slice
    then the caller will notice this.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 20, '14 at 5:36p
activeJul 24, '14 at 4:51p
posts6
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase