summaryrefslogtreecommitdiff
path: root/python/vyos/remote.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-11 20:36:39 +0200
committerGitHub <noreply@github.com>2020-04-11 20:36:39 +0200
commitda03bbf8767be74957baae68bf9ffc0e9f56ddac (patch)
treebcdfb217eb1bc75d06ce5af604836c6be999a749 /python/vyos/remote.py
parent143d292209b6ebe24f90667f2d5edd0216151163 (diff)
parent5763af8cbe7e2ad35a1eb336e77a6fe74ac2534e (diff)
downloadvyos-1x-da03bbf8767be74957baae68bf9ffc0e9f56ddac.tar.gz
vyos-1x-da03bbf8767be74957baae68bf9ffc0e9f56ddac.zip
Merge pull request #329 from thomas-mangin/T2226
util: T2226: improvement and fixes
Diffstat (limited to 'python/vyos/remote.py')
-rw-r--r--python/vyos/remote.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py
index f918461d1..1b4d3876e 100644
--- a/python/vyos/remote.py
+++ b/python/vyos/remote.py
@@ -18,7 +18,8 @@ import os
import re
import fileinput
-from vyos.util import cmd, DEVNULL
+from vyos.util import cmd
+from vyos.util import DEVNULL
def check_and_add_host_key(host_name):
@@ -31,10 +32,10 @@ def check_and_add_host_key(host_name):
mode = 0o600
os.mknod(known_hosts, 0o600)
- keyscan_cmd = 'ssh-keyscan -t rsa {} 2>/dev/null'.format(host_name)
+ keyscan_cmd = 'ssh-keyscan -t rsa {}'.format(host_name)
try:
- host_key = cmd(keyscan_cmd, shell=True, stderr=DEVNULL)
+ host_key = cmd(keyscan_cmd, stderr=DEVNULL)
except OSError:
sys.exit("Can not get RSA host key")
@@ -61,9 +62,9 @@ def check_and_add_host_key(host_name):
print("Host key has changed!")
print("If you trust the host key fingerprint below, continue.")
- fingerprint_cmd = 'ssh-keygen -lf /dev/stdin <<< "{}"'.format(host_key)
+ fingerprint_cmd = 'ssh-keygen -lf /dev/stdin'
try:
- fingerprint = cmd(fingerprint_cmd, shell=True, stderr=DEVNULL)
+ fingerprint = cmd(fingerprint_cmd, stderr=DEVNULL, input=host_key)
except OSError:
sys.exit("Can not get RSA host key fingerprint.")
@@ -125,7 +126,7 @@ def get_remote_config(remote_file):
# Try header first, and look for 'OK' or 'Moved' codes:
curl_cmd = 'curl {0} -q -I {1}'.format(redirect_opt, remote_file)
try:
- curl_output = cmd(curl_cmd, shell=True)
+ curl_output = cmd(curl_cmd)
except OSError:
sys.exit(1)
@@ -142,6 +143,6 @@ def get_remote_config(remote_file):
curl_cmd = 'curl {0} -# {1}'.format(redirect_opt, remote_file)
try:
- return cmd(curl_cmd, shell=True, stderr=None)
+ return cmd(curl_cmd, stderr=None)
except OSError:
return None