You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Jorge Lopez <Jo...@eu.equinix.com.INVALID> on 2022/11/04 12:40:16 UTC

Set sftp path in ssh connections

Hi,

I'm using my own development of guacamole server through a django project and I will like to specify and sftp path for drag and drop files upload. I tried with sftp-root-directory as specified in https://guacamole.apache.org/doc/gug/configuring-guacamole.html#ssh but I think it's just for file browser, because if a user drops a file in the window the file is upload to the user's home directory, not at the path specified in sftp-root-directory, and, in some cases this path doesn't exist so file is not uploaded or I can't find where the file is uploaded.

Here is an example of my python code:

parameters = {

    'protocol': 'ssh',

    'hostname': host,

    'port': credential.port,

    'username': credential.user,

    'password': password,

    'enable_sftp': enable_sftp,

    'sftp_root_directory': '/tmp/test',

    'recording_path': record_path,

    'create_recording_path': 'true',

    'recording_name': record_name,

    'create_typescript_path': 'true',

    'typescript_path': session_path,

    'typescript_name': record_name

}

As I see in guacd container logs, there is no error and sftp is connected succesfully. With RDP connections 'drive_path' option is working as expected, but not for ssh. I also tried adding the absolute path to the filename once I created the FileStream in my .js client implementation:

filename = `/tmp/test/${filename}`

let stream = guac.createFileStream(mimetype, filename);

But as I see in guacd logs, it's raising an error

Filename "/tmp/test/test.docx" is invalid or resulting path is too long



What I'm doing wrong? Is there a way to change the file's default path?



Thanks




Jorge López Díaz
Managed Services Operations Senior Analyst

EQUINIX | Calle Valgrande 6, 28108, Alcobendas, Madrid, España
E jorge.lopez@eu.equinix.com<ma...@eu.equinix.com> | M +34682449912
 [signature_3696389115] <https://equinix.qualtrics.com/jfe/form/SV_5tZRNCGwOKna7A1>
[Twitter]<https://twitter.com/equinix>[LinkedIn]<http://www.linkedin.com/company/equinix>[Facebook]<http://www.facebook.com/Equinix>[YouTube]<http://www.youtube.com/user/equinixvideos>

This email is from Equinix (EMEA) B.V. or one of its associated companies in the territory from where this email has been sent. This email, and any files transmitted with it, contains information which is confidential, is solely for the use of the intended recipient and may be legally privileged. If you have received this email in error, please notify the sender and delete this email immediately. Equinix (EMEA) B.V.. Registered Office: Amstelplein 1, 1096 HA Amsterdam, The Netherlands. Registered in The Netherlands No. 57577889.

Re: Set sftp path in ssh connections

Posted by Michael Jumper <mj...@apache.org>.
On Fri, Nov 4, 2022 at 5:40 AM Jorge Lopez
<Jo...@eu.equinix.com.invalid> wrote:

> Hi,
>
> I'm using my own development of guacamole server through a django project
> and I will like to specify and sftp path for drag and drop files upload. I
> tried with sftp-root-directory as specified in
> https://guacamole.apache.org/doc/gug/configuring-guacamole.html#ssh but I
> think it's just for file browser, because if a user drops a file in the
> window the file is upload to the user's home directory, not at the path
> specified in sftp-root-directory, and, in some cases this path doesn't
> exist so file is not uploaded or I can't find where the file is uploaded.
>

The "sftp-root-directory" parameter only affects the file browser. From the
documentation for that parameter:

"The directory to expose to connected users via Guacamole’s file browser.
If omitted, the root directory will be used by default."


Uploads that are just dragged into the browser window will go to whichever
path the SFTP server considers the default, typically the user's home
directory.

As I see in guacd container logs, there is no error and sftp is connected
> succesfully. With RDP connections 'drive_path' option is working as
> expected, but not for ssh. I also tried adding the absolute path to the
> filename once I created the FileStream in my .js client implementation:
>
> filename = `/tmp/test/${filename}`
>
> let stream = guac.createFileStream(mimetype, filename);
>
> But as I see in guacd logs, it's raising an error
>
> Filename "/tmp/test/test.docx" is invalid or resulting path is too long
>
>
The filename of a file stream is just the filename of the destination file,
not the destination path. The attempt to upload is being rejected because
of the inclusion of path separators in that filename. To upload to a
specific path, you'll need to use the same mechanism as the file browser,
leveraging the filesystem object received at the beginning of the
connection and then createOutputStream() of that filesystem object instead
of the client-level createFileStream(). For example:

// After setting a handler for guac.onfilesystem so we have a reference to
any received filesystem ...
let stream = filesystem.createOutputStream('application/octet-stream',
'/tmp/test/test.docx');


Unlike the file stream, the filesystem object has defined behavior for path
separators in stream names and will handle those as directories.

- Mike