Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable SSH host key checking for all operations except when adding repo #717

Merged
merged 5 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/vorta/borg/borg_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def __init__(self, cmd, params, parent=None):
env = os.environ.copy()
env['BORG_HOSTNAME_IS_UNIQUE'] = '1'
env['BORG_RELOCATED_REPO_ACCESS_IS_OK'] = '1'
env['BORG_RSH'] = 'ssh'

if 'additional_env' in params:
env = {**env, **params['additional_env']}

password = params.get('password')
if password is not None:
env['BORG_PASSPHRASE'] = password
Expand All @@ -70,7 +75,6 @@ def __init__(self, cmd, params, parent=None):
if env.get('BORG_PASSCOMMAND', False):
env.pop('BORG_PASSPHRASE', None) # Unset passphrase

env['BORG_RSH'] = 'ssh -oStrictHostKeyChecking=no'
ssh_key = params.get('ssh_key')
if ssh_key is not None:
ssh_key_path = os.path.expanduser(f'~/.ssh/{ssh_key}')
Expand Down
6 changes: 4 additions & 2 deletions src/vorta/borg/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .borg_thread import BorgThread
from vorta.models import RepoModel
from vorta.keyring.abc import get_keyring
import os

FakeRepo = namedtuple('Repo', ['url', 'id', 'extra_borg_arguments'])
FakeProfile = namedtuple('FakeProfile', ['repo', 'name', 'ssh_key'])
Expand Down Expand Up @@ -35,7 +34,10 @@ def prepare(cls, params):
cmd = ["borg", "info", "--info", "--json", "--log-json"]
cmd.append(profile.repo.url)

os.environ['BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK'] = "yes"
ret['additional_env'] = {
'BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK': "yes",
'BORG_RSH': 'ssh -oStrictHostKeyChecking=no'
}

if params['password'] == '':
ret['password'] = '999999' # Dummy password if the user didn't supply one. To avoid prompt.
Expand Down
4 changes: 4 additions & 0 deletions src/vorta/borg/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def prepare(cls, params):
cmd.append(f"--encryption={params['encryption']}")
cmd.append(params['repo_url'])

ret['additional_env'] = {
'BORG_RSH': 'ssh -oStrictHostKeyChecking=no'
}

ret['encryption'] = params['encryption']
ret['password'] = params['password']
ret['ok'] = True
Expand Down