{"thread":{"id":"15546","subject":"[JGIT PATCH] Add support for ~/.ssh/config PreferredAuthentications","startedAt":"2008-09-16T05:48:17Z","lastAt":"2008-09-16T05:48:17Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"90804","messageId":"1221544097-51484-1-git-send-email-spearce@spearce.org","threadId":"15546","inReplyTo":null,"subject":"[JGIT PATCH] Add support for ~/.ssh/config PreferredAuthentications","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-16T05:48:17Z","receivedAt":"2008-09-16T05:48:17Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Some configurations may wish to disable interactive methods of\nauthentication, such as when running from automated cron or batch\nstyle jobs that have no user available.\n\nTypically in an OpenSSH based system this would be configured on a\nper-host basis in the current user's ~/.ssh/config file, by setting\nPreferredAuthentications to the list of authentication methods\n(e.g. just \"publickey\") that are reasonable.\n\nJSch honors this configuration setting, but we need to transfer it\nfrom our own OpenSshConfig class, otherwise it has no knowledge of\nthe setting.\n\nhttp://code.google.com/p/egit/issues/detail?id=33\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../spearce/egit/ui/EclipseSshSessionFactory.java  |    4 ++++\n .../jgit/transport/DefaultSshSessionFactory.java   |    4 ++++\n .../org/spearce/jgit/transport/OpenSshConfig.java  |   12 ++++++++++++\n 3 files changed, 20 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/EclipseSshSessionFactory.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/EclipseSshSessionFactory.java\nindex 640a165..67c5f16 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/EclipseSshSessionFactory.java\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/EclipseSshSessionFactory.java\n@@ -50,6 +50,10 @@ if (pass != null)\n \t\t\tsession.setPassword(pass);\n \t\telse\n \t\t\tnew UserInfoPrompter(session);\n+\n+\t\tfinal String pauth = hc.getPreferredAuthentications();\n+\t\tif (pauth != null)\n+\t\t\tsession.setConfig(\"PreferredAuthentications\", pauth);\n \t\treturn session;\n \t}\n \ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java b/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java\nindex 74fca66..b6f58f0 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java\n@@ -103,6 +103,10 @@ if (pass != null)\n \t\t\tsession.setPassword(pass);\n \t\telse\n \t\t\tsession.setUserInfo(new AWT_UserInfo());\n+\n+\t\tfinal String pauth = hc.getPreferredAuthentications();\n+\t\tif (pauth != null)\n+\t\t\tsession.setConfig(\"PreferredAuthentications\", pauth);\n \t\treturn session;\n \t}\n \ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java\nindex cf7c388..748199c 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/OpenSshConfig.java\n@@ -278,6 +278,8 @@ if (ret.isAbsolute())\n \n \t\tString user;\n \n+\t\tString preferredAuthentications;\n+\n \t\tvoid copyFrom(final Host src) {\n \t\t\tif (hostName == null)\n \t\t\t\thostName = src.hostName;\n@@ -287,6 +289,8 @@ if (identityFile == null)\n \t\t\t\tidentityFile = src.identityFile;\n \t\t\tif (user == null)\n \t\t\t\tuser = src.user;\n+\t\t\tif (preferredAuthentications == null)\n+\t\t\t\tpreferredAuthentications = src.preferredAuthentications;\n \t\t}\n \n \t\t/**\n@@ -317,5 +321,13 @@ public File getIdentityFile() {\n \t\tpublic String getUser() {\n \t\t\treturn user;\n \t\t}\n+\n+\t\t/**\n+\t\t * @return return the preferred authentication methods, separated by\n+\t\t *         commas if more than one authentication method is preferred.\n+\t\t */\n+\t\tpublic String getPreferredAuthentications() {\n+\t\t\treturn preferredAuthentications;\n+\t\t}\n \t}\n }\n-- \n1.6.0.1.337.g5c7d67\n"}]}