Skip to content

Commit 27b51f6

Browse files
committed
Skip SSH host key files that do not exist
Since we now do not generate a DSA host key file anymore, but keep it in the list of potential keys so that existing keys still work, it can happen that the files for DSA (and Ed25519) are getting loaded but they do not exist. This results in an error in the log. So instead check if the file exists and only try to load files that exist. This prevents from errors (which are none) being spammed in the log.
1 parent 366a14f commit 27b51f6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package com.gitblit.transport.ssh;
2020

21+
import java.io.File;
2122
import java.io.FileInputStream;
2223
import java.io.InputStreamReader;
2324
import java.security.KeyFactory;
@@ -122,6 +123,11 @@ private boolean setNextObject()
122123
{
123124
while (iterator.hasNext()) {
124125
String file = iterator.next();
126+
File f = new File(file);
127+
if (!f.isFile()) {
128+
log.debug("File does not exist, skipping {}", file);
129+
continue;
130+
}
125131
nextKeyPair = doLoadKey(file);
126132
if (nextKeyPair != null) {
127133
nextKeyPairSet = true;

0 commit comments

Comments
 (0)