Den*_*edo 4 ssh gradle gradle-plugin private-key
我无法使用Gradle SSH插件和我的私钥连接到SSH主机.
在build.gradle工作中指定密码:
remotes {
webServer {
host = '<IP>'
user = '<USER>'
password = '<PASSWORD>'
}
}
Run Code Online (Sandbox Code Playgroud)
但是为了避免在构建文件中写入密码,我将环境设置为使用我的私钥进行连接,而无需从shell输入密码:
ssh <user>@<ip>
Run Code Online (Sandbox Code Playgroud)
这个命令可以在shell中运行,但我无法通过Gradle插件实现这一点.这是我的配置:
remotes {
webServer {
host = '<IP>'
user = '<USER>'
identity = file("${System.getProperty('user.home')}/.ssh/id_rsa")
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
引起:com.jcraft.jsch.JSchException:USERAUTH在com.jcraft.jsch.UserAuthPublicKey.start失败(UserAuthPublicKey.java:119)
由于我能够从shell连接,我的配置有什么问题?
Den*_*edo 11
我通过添加agent = true属性来修复此问题:
remotes {
webServer {
host = '54.233.77.171'
user = 'denis'
agent = true
identity = file("${System.getProperty('user.home')}/.ssh/id_rsa")
}
}
Run Code Online (Sandbox Code Playgroud)
agent - 如果设置了此选项,将在身份验证时使用Putty Agent或ssh-agent
有关更多信息:连接设置
我在分析了UserAuthPublicKey类之后尝试了这个属性:
if(userinfo==null) throw new JSchException("USERAUTH fail");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3543 次 |
| 最近记录: |