我正尝试在Kotlin的build.gradle.kts中配置gradle-ssh-plugin。
我发现了这个问题,这对我帮助很大。只要我把我已知的主机条目放在插件knownHosts: new File("${System.properties['user.home']}/.ssh/known_hosts"),
的标准位置,一切都很好。
但是我想为这个文件配置一个不同的位置,因为我想把这个文件放在git repo中。
但是不管我在设置中设置了什么,它仍然在使用标准位置,我试过以下方法:
tasks.create("deploy") {
val myServer = Remote(
mapOf<String, String>(
"host" to "192.168.1.1",
"user" to "username",
"password" to "password"))
doLast {
ssh.run(delegateClosureOf<RunHandler> {
settings(
delegateClosureOf<PerServiceSettings>{
mapOf(
"knownHosts" to AllowAnyHosts.instance,
)
}
)
session(
myServer,
delegateClosureOf<SessionHandler> {
put(
hashMapOf(
"from" to "${project.rootDir}/deploy",
"into" to "/home/username/"))
})
})
}
}
字符串
和
tasks.create("deploy") {
val myServer = Remote(
mapOf<String, String>(
"host" to "192.168.1.1",
"user" to "username",
"password" to "password"))
ssh.settings (
delegateClosureOf<GlobalSettings>{
mapOf(
"knownHosts" to AllowAnyHosts.instance,
)
}
)
doLast {
ssh.run(delegateClosureOf<RunHandler> {
session(
myServer,
delegateClosureOf<SessionHandler> {
put(
hashMapOf(
"from" to "${project.rootDir}/deploy",
"into" to "/home/username/"))
})
})
}
}
型
1条答案
按热度按时间von4xj4u1#
字符串
将配置移至远程,