Page MenuHomeVyOS Platform

using load with scp/sftp and a username and password does not work
Closed, ResolvedPublicBUG

Description

The password is not correctly used.

Details

Version
202004110117
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

This naive patch fixes the issue but I am not sure it is correct and will let @jestabro decide how to handle it (as git gives him as the author of the file)

diff --git a/python/vyos/remote.py b/python/vyos/remote.py
index f8a21f0..a69537e 100644
--- a/python/vyos/remote.py
+++ b/python/vyos/remote.py
@@ -140,10 +140,18 @@ def get_remote_config(remote_file):
                 print('HTTP error: {0} {1}'.format(*val))
                 sys.exit(1)

-    if request['user'] and not request['passwd']:
-        curl_cmd = 'curl -# -u {0} {1}'.format(request['user'], remote_file)
+    if request['protocol'] in ('scp', 'sftp'):
+        if request['user'] and not request['passwd']:
+            # not sure what happens if a username/password has ":"
+            curl_cmd = 'curl -# -u {0}:{1} {2}'.format(request['user'], request['passwd'], remote_file)
+        else:
+            curl_cmd = 'curl {0} -# {1}'.format(redirect_opt, remote_file)
+    # XXX: This probably only works for http/https ?
     else:
-        curl_cmd = 'curl {0} -# {1}'.format(redirect_opt, remote_file)
+        if request['user'] and not request['passwd']:
+            curl_cmd = 'curl -# -u {0} {1}'.format(request['user'], remote_file)
+        else:
+            curl_cmd = 'curl {0} -# {1}'.format(redirect_opt, remote_file)

     try:
         config_file = subprocess.check_output(curl_cmd, shell=True,
`
thomas-mangin renamed this task from using load with a username and password does not work to using load with scp/sftp and a username and password does not work.Apr 11 2020, 9:31 AM

True, it doesn't currently work; that patch has various problems.

The use of 'user:passwd' is deprecated in rfc 3986, and was carried over in the rewrite from perl to python to maintain backwards compatibility; it should probably be retired. I will either fix or retire.

It is a useful feature .. please do not kill, This patch will fix things until it can be looked into 🤕

jestabro moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.
erkin set Issue type to Bug (incorrect behavior).Aug 30 2021, 7:12 AM
erkin removed a subscriber: Global Notifications.