Allow sshd.listenAddress = off to disable the daemon
We might not want to run the internal SSHD, ever, on this system. In such cases permit off for listenAddress so that we don't initialize a server key, or even try to load it at startup. Change-Id: Ia57c3aa24413d64e10e0440f758b3b18f881ddd9 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -54,13 +54,20 @@ class InitSshd implements InitStep {
|
||||
String hostname = "*";
|
||||
int port = 29418;
|
||||
String listenAddress = sshd.get("listenAddress");
|
||||
if (listenAddress != null && !listenAddress.isEmpty()) {
|
||||
if (isOff(listenAddress)) {
|
||||
hostname = "off";
|
||||
} else if (listenAddress != null && !listenAddress.isEmpty()) {
|
||||
final InetSocketAddress addr = SocketUtil.parse(listenAddress, port);
|
||||
hostname = SocketUtil.hostname(addr);
|
||||
port = addr.getPort();
|
||||
}
|
||||
|
||||
hostname = ui.readString(hostname, "Listen on address");
|
||||
if (isOff(hostname)) {
|
||||
sshd.set("listenAddress", "off");
|
||||
return;
|
||||
}
|
||||
|
||||
port = ui.readInt(port, "Listen on port");
|
||||
sshd.set("listenAddress", SocketUtil.format(hostname, port));
|
||||
|
||||
@@ -73,6 +80,12 @@ class InitSshd implements InitStep {
|
||||
generateSshHostKeys();
|
||||
}
|
||||
|
||||
private static boolean isOff(String listenHostname) {
|
||||
return "off".equalsIgnoreCase(listenHostname)
|
||||
|| "none".equalsIgnoreCase(listenHostname)
|
||||
|| "no".equalsIgnoreCase(listenHostname);
|
||||
}
|
||||
|
||||
private void generateSshHostKeys() throws InterruptedException, IOException {
|
||||
if (!site.ssh_key.exists() //
|
||||
&& !site.ssh_rsa.exists() //
|
||||
|
Reference in New Issue
Block a user