bgp: use host's ssh host key if not specified
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
5c78159a36
commit
25e19df614
@ -21,6 +21,7 @@ import paramiko
|
||||
import sys
|
||||
from copy import copy
|
||||
from oslo.config import cfg
|
||||
import os.path
|
||||
|
||||
from ryu.lib import hub
|
||||
from ryu import version
|
||||
@ -79,11 +80,25 @@ Hello, this is Ryu BGP speaker (version %s).
|
||||
|
||||
transport = paramiko.Transport(sock)
|
||||
transport.load_server_moduli()
|
||||
host_key = paramiko.RSAKey.from_private_key_file(CONF.cli_ssh_hostkey)
|
||||
host_key = self._find_ssh_server_key()
|
||||
transport.add_server_key(host_key)
|
||||
self.transport = transport
|
||||
transport.start_server(server=self)
|
||||
|
||||
def _find_ssh_server_key(self):
|
||||
if CONF.cli_ssh_hostkey:
|
||||
return paramiko.RSAKey.from_private_key_file(CONF.cli_ssh_hostkey)
|
||||
elif os.path.exists("/etc/ssh_host_rsa_key"):
|
||||
# OSX
|
||||
return paramiko.RSAKey.from_private_key_file(
|
||||
"/etc/ssh_host_rsa_key")
|
||||
elif os.path.exists("/etc/ssh/ssh_host_rsa_key"):
|
||||
# Linux
|
||||
return paramiko.RSAKey.from_private_key_file(
|
||||
"/etc/ssh/ssh_host_rsa_key")
|
||||
else:
|
||||
return paramiko.RSAKey.generate(1024)
|
||||
|
||||
def check_auth_none(self, username):
|
||||
return paramiko.AUTH_SUCCESSFUL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user