Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if there is a turtorial about how to login by ssh keyfile or codeconfig #44

Open
yasz opened this issue Oct 30, 2018 · 1 comment
Open

Comments

@yasz
Copy link

yasz commented Oct 30, 2018

No description provided.

@yasz yasz changed the title if there is a turtoial about how to login ssh by keyfile or codeconfig if there is a turtorial about how to login ssh by keyfile or codeconfig Oct 30, 2018
@yasz yasz changed the title if there is a turtorial about how to login ssh by keyfile or codeconfig if there is a turtorial about how to login ssh keyfile or codeconfig Oct 30, 2018
@yasz yasz changed the title if there is a turtorial about how to login ssh keyfile or codeconfig if there is a turtorial about how to login by ssh keyfile or codeconfig Oct 30, 2018
@Openpalm
Copy link

Openpalm commented Sep 30, 2019

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,

  1. i keep a template of the hostConfig file which i fill out and write using twig.
  2. 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) } //
   }
//..
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants