FAQ
Hi all,

My aim is to be able to send/receive SFTP packets as described in
https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt
over an ssh channel.

So far I have been successful in creating an ssh connection using the
following code :

=============[test.go]==============================================
package main

import (
     "code.google.com/p/go.crypto/ssh"
     "flag"
     "fmt"
     "log"
     "net"
     "os"
)

var (
     USER = flag.String("user", os.Getenv("USER"), "ssh username")
     HOST = flag.String("host", "127.0.0.1", "ssh server hostname")
     PASS = flag.String("pass", "", "ssh password")
)

func init() { flag.Parse() }


//password implements the ClientPassword
interface

type password string

func (p password) Password(user string) (string, error) {
     return string(p), nil
}


func main() {

     var auths []ssh.ClientAuth
     if agent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err ==
nil {
         auths = append(auths,
ssh.ClientAuthAgent(ssh.NewAgentClient(agent)))
     }
     if *PASS != "" {
         auths = append(auths, ssh.ClientAuthPassword(password(*PASS)))
     }

     config := &ssh.ClientConfig{

     User: *USER,
     Auth: auths,
     }
     addr := fmt.Sprintf("%s:%d", *HOST, 22)
     conn, err := ssh.Dial("tcp", addr, config)
     if err != nil {
     log.Fatalf("unable to connect to [%s]: %v", addr, err)
     }
     defer conn.Close()
     /* TODO : Create an SFTP session */
}

============================================================================

As per https://filezilla-project.org/specs/rfc4254.txt [section 6.5], I
need to send a channel request with subsystem name = "sftp"

I saw in http://godoc.org/code.google.com/p/go.crypto/ssh#Channel a
definition of Channel, but unable to find any mechanism that request for a
channel to be created and returns an object that implements "Channel"

Any clue on creating an sftp session would be very helpful.

Thanks a lot,
Dennis




--
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/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 22, '13 at 4:41a
activeJul 22, '13 at 4:41a
posts1
users1
websitegolang.org

1 user in discussion

Dennis Francis: 1 post

People

Translate

site design / logo © 2022 Grokbase