scala-ssh
                                
                                 scala-ssh copied to clipboard
                                
                                    scala-ssh copied to clipboard
                            
                            
                            
                        if there is a turtorial about how to login by ssh keyfile or codeconfig
i have an initial imperative way of doing this, so please provide a functional style. i will eventually, no time for now.
my method is simple,
- i keep a template of the hostConfig file which i fill out and write using twig.
- i always write a config file before calling SSH()
#keyfile should know: scala-ssh looks for files under ~/.scala-ssh
i use a template and it looks like this:
@(sshHost: String)
login-type  = keyfile
username    = root
keyfile     = ~/.ssh/id_rsa
host-name   = @sshHost
port        = 22
command-timeout = 5000
fingerprint = any
write the hostconfig file under ~/.scala-ssh keyfile is your ~/.ssh/id_rsa
example code
object SecureShellWrapper {
import java.io._
def writeHostFile(hostString) { 
   val file = new File(s"~/.scala-ssh/$hostString")
   val fw =   new BufferedWriter(new FileWriter(file))
   fw.write(twigPathToTemplate(hostString).render)
   fw.close()
 } 
def psa(host: String) { 
     writeHostFile(host)
     SSH(host) { client => 
      client.exec("ps -a").map { out => println(out.exitCode) } //
   }
//..
}