server = SSHTunnelForwarder(
ssh_address_or_host='33.103.212.66', # 跳板机B地址
ssh_port=22, # 跳板机B端口
ssh_username='root',
ssh_password='crmQ@cI@voBe%k!fNdffdafdfsdf',
# local_bind_address=('127.0.0.1', 22), # 这里必须填127.0.0.1
remote_bind_address=('10.111.12.123', 3306) # 目标机器A地址,端口
)
server.start()
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': server.local_bind_port,
'NAME': 'db_test',
'USER': 'jusr8pr5kbrj',
'PASSWORD': 'TbH9&UJR8LZh7oZ7'
''
''
'',
'OPTIONS': {
'sql_mode': 'traditional',
}
}
}