Skip to content

Commit 57854ff

Browse files
committed
Implement resolution of '~' in keyfile location
1 parent 5518597 commit 57854ff

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "scala-ssh"
22

3-
version := "0.6.0"
3+
version := "0.6.1-SNAPSHOT"
44

55
organization := "com.decodified"
66

src/main/scala/com/decodified/scalassh/HostConfig.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ abstract class FromStringsHostConfigProvider extends HostConfigProvider {
103103
keyfile.map {
104104
case kf if kf.startsWith("+") => kf.tail :: DefaultKeyLocations
105105
case kf => kf :: Nil
106-
}.getOrElse(DefaultKeyLocations)
106+
}.getOrElse(DefaultKeyLocations).map(
107+
_.replaceFirst("^~/", System.getProperty("user.home") + '/').replace('/', File.separatorChar)
108+
)
107109
)
108110
}
109111
}

src/main/scala/com/decodified/scalassh/SshLogin.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ case class PublicKeyLogin(
3131
) extends SshLogin
3232

3333
object PublicKeyLogin {
34-
lazy val DefaultKeyLocations = {
35-
val base = System.getProperty("user.home") + File.separator + ".ssh" + File.separator
36-
(base + "id_rsa") :: (base + "id_dsa") :: Nil
37-
}
34+
lazy val DefaultKeyLocations = "~/.ssh/id_rsa" :: "~/.ssh/id_dsa" :: Nil
3835
def apply(user: String): PublicKeyLogin =
3936
apply(user, None, DefaultKeyLocations)
4037
def apply(user: String, keyfileLocations: String*): PublicKeyLogin =

0 commit comments

Comments
 (0)