Hi all,

My aim is to be able to send/receive SFTP packets as described in
over an ssh channel.

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

package main

import (

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

func init() { flag.Parse() }

//password implements the ClientPassword

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,
     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,

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 @
postedJul 22, '13 at 4:41a
activeJul 22, '13 at 4:41a

1 user in discussion

Dennis Francis: 1 post



site design / logo © 2022 Grokbase