Hi,

To start off I'm fairly new to Go, I would just like to know the following:

If I make changes similar to yours in common.go, how would I be able to 
make use of them in my main package.

For example in my common.go file I added the following
==== common.go ====
func returnCiphers() []string {
return supportedCiphers
}

In my main package, how will I call it as the following does not seem to 
work:
==== main.go ====
fmt.Println(ssh.returnCiphers())

Assistance will greatly be appreciated.

On Sunday, July 21, 2013 at 4:29:25 AM UTC+2, Dennis Francis wrote:
>
> Hi all,
>
>
> I used the following code (derived from 
> https://github.com/davecheney/socksie/blob/master/main.go) which uses the 
> SSHAgent support in the ssh package 
> to provide authentication to connect to a sftp server.
>
>
> ===========[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 {
>     fmt.Println("ssh-agent")
>         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()
>
> }
>
>
> ============================================================================
>
> I also added the following debug statement to 
> code.google.com/p/go.crypto/ssh/common.go
>
> func findCommonCipher(clientCiphers []string, serverCiphers []string) 
> (commonCipher string, ok bool) {
>     for _, clientCipher := range clientCiphers {
>     for _, serverCipher := range serverCiphers {
>             // reject the cipher if we have no cipherModes 
> definition                                                                    
>                                                                          
>
>             if clientCipher == serverCipher && cipherModes[clientCipher] 
> != nil {
>         return clientCipher, true
>             }
>         }
>     }
>     fmt.Println("no common cipher clientCiphers=", clientCiphers, 
> "serverCiphers=", serverCiphers)
>     return
> }
>
> Output
> ======
>
> myhost ~ $ ./test -host <server> -user <username>
> ssh-agent
> no common cipher clientCiphers= [aes128-ctr aes192-ctr aes256-ctr 
> arcfour256 arcfour128] serverCiphers= [aes128-cbc blowfish-cbc aes256-cbc 
> aes192-cbc 3des-cbc]
> No common writer cipher Algo
> 2013/07/20 22:01:33 unable to connect to [<server>:22]: handshake failed: 
> ssh: no common algorithms
>
>
> I see that from the ssh/cipher.go that there is no support for *-cbc 
> ciphers, so I like to add support for these.
>
> I see from crypto/cipher pkg, that CBC ciphers have different encrypter 
> and decrypter functions and the ssh/cipher.go/createCipher() function 
> doesn't have an indicator that specifies whether the current operation is 
> encryption or decryption. 
>
> Can someone give a clue on how to add cbc cipher support to ssh/cipher.go ?
>
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to