2016-01-08 152 views
2

我使用gradle編寫了一個springboot項目,我想部署它。使用gradle部署springboot項目:執行失敗的任務':deploytest'

這裏來的我的代碼部分build.gradle

remotes { 
    localtest { 
    host = '192.168.0.116' 
    user = 'root' 
    password = '*****' 
    } 
} 

task deploytest(dependsOn: build) << { 
    ssh.run { 
    session(remotes.localtest) { 
     put from: 'build/libs/test-0.0.1-SNAPSHOT.jar', into: '/opt/test/' 
     execute "cd /opt/tieba" 
     execute 'nohup java -jar -Dspring.profiles.active=test test-0.0.1-SNAPSHOT.jar & echo $! > application.pid' 
    } 
    } 
} 

然後我跑gradle deploytest,但它滿足了一個問題:

FAILURE: Build failed with an exception. 

* Where: 
Build file 'E:\github\spring-projects\test\build.gradle' line: 97 

* What went wrong: 
Execution failed for task ':deploytest'. 
> reject HostKey: 192.168.0.116 

詳細

org.gradle。 api.tasks.TaskExecutionException:任務':deploytest'的執行失敗。

產生的原因:com.jcraft.jsch.JSchException:拒絕HostKey:192.168.0.116

gradle error details 01 gradle error details 02

+0

您可以登錄到該主機的終端? – AdamSkywalker

+0

服務器的公鑰是否已經在您的known_hosts文件中?這可能是你面臨的問題:http://anahorny.blogspot.co.at/2013/05/solution-for-comjcraftjschjschexception.html? –

+1

@DavidTanzer感謝您的回答,它幫助了很多! –

回答

0

我通過SSH配置設置knownHosts = allowAnyHosts修復它,完成設置

remotes { 
    localtest { 
    host = '192.168.0.116' 
    user = 'root' 
    knownHosts = allowAnyHosts 
    password = '*****' 
    } 
} 
1

得到了同樣的問題,服務器使用ED25519。

我刪除了~/.ssh/known_hosts相應的線,與ssh-keyscan -t rsa myserver.tld的RSA旗幟和複製的結果返回給known_host

看起來比設定knownHosts = allowAnyHosts

+0

'ssh-keyscan -t rsa server.com >>〜/ .ssh/known_hosts' –

相關問題