Created
December 17, 2013 12:12
-
-
Save codeck/8004013 to your computer and use it in GitHub Desktop.
call jgitenv.setup() before any jgit call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object jgitenv { | |
def setup() { | |
val jschConfigSessionFactory = new JschConfigSessionFactory() { | |
override def createDefaultJSch(fs:FS) = { | |
val jsch = new JSch(); | |
try { | |
jsch.addIdentity("..\\id_rsa"); //_.pub must exist | |
jsch.setKnownHosts("..\\known_hosts"); | |
} catch { | |
case e: JSchException => { | |
e.printStackTrace(); | |
} | |
} | |
jsch | |
} | |
override def configure(host: OpenSshConfig.Host, session: Session) { | |
session.setConfig("StrictHostKeyChecking", "no"); | |
//session.setConfig("IdentityFile", "..\\id_rsa") | |
session.setConfig("PreferredAuthentications", "publickey"); | |
//session.setConfig("PreferredAuthentications", "gssapi-with-mic"); | |
//session.setPassword("12345678") | |
} | |
} | |
SshSessionFactory.setInstance(jschConfigSessionFactory); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more reference:
http://dev.vaadin.com/svn/incubator/Arvue/VersionControl/src/org/nest/versioncontrol/authentication/GitSshSessionFactory.java
https://gist.github.com/quidryan/5449155