Bug 428676 - When adding adding network folder in dolphin for ssh (via sftp or fish) getting message Unable to connect to server
Summary: When adding adding network folder in dolphin for ssh (via sftp or fish) getti...
Status: RESOLVED NOT A BUG
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: SFTP (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-04 11:15 UTC by Hans
Modified: 2020-11-06 08:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans 2020-11-04 11:15:26 UTC
SUMMARY

This doesn't work for sftp and fish when execute via dolphin add network (or dophin command bar). It DOES work straight from the command line

STEPS TO REPRODUCE

1 I have an ssh agent running with following in .bashrc (as per arch wiki). 


# pass ssh-agent to kdewallet
export SSH_ASKPASS='/usr/bin/ksshaskpass'

# start ssh agent if not running

if ! pgrep -u "$USER" ssh-agent > /dev/null; then
    ssh-agent > "$XDG_RUNTIME_DIR/ssh-agent.env"
fi
if [[ ! "$SSH_AUTH_SOCK" ]]; then
    source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
fi


2 I am using kdewallet to store the passphrase.
ssh-add -q ~/Keys/AWS/aws.pem </dev/null

If done for the first time it will popup and ask for the passphrase and if save is selected it will store in kde wallet.

3 If I connect from command line with ssh xxx@xxx.xx.xx.xx it works
  if I connect from command line with sftp xxx@xxx.xx.xx.xx it works



OBSERVED RESULT
When I try to add a network folder in the wizard or directly in the bar, I get the message: Unable to connect to server. Please check your settings and try again. It doesn't work for sftp and fish

EXPECTED RESULT

I should be able to connect as I can do through the command line.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Arch
(available in About System)
KDE Plasma Version:5.19.5 
KDE Frameworks Version: 5.74
Qt Version: 5.15.1

ADDITIONAL INFORMATION
Comment 1 Harald Sitter 2020-11-05 14:40:32 UTC
Can you elaborate on your intended ssh-agent involvement here? Your .bashrc is irrelevant unless you start your entire desktop session from a bash as that entire sourcing dancing will do nothing. Bash is not involved in starting up a desktop session.
Comment 3 Hans 2020-11-05 14:58:47 UTC
Harald,

Yea I guess I gave a bit too much detail (-: 

In brief, I have an ssh-agent running, added a key, using the kde-wallet to store the passphrase (via SSH_ASKPASS) and it is working from command line with ssh and sftp. It does not work via dolphin, does this not use the ssh-agent?

I will try to get the libssh output.

Hans
Comment 4 Hans 2020-11-05 15:12:45 UTC
Hi,

Even stranger:

When executing as per suggested website it connects and works!!!

KIO_SFTP_LOG_VERBOSITY=10 KDE_FORK_SLAVES=1 QT_LOGGING_RULES="log_kio_sftp=true;" dolphin --new-window sftp://xx@xx.xx.xxx.xxx

BUT when doing the following, I am getting authentication error!

dolphin --new-window sftp://xx@xx.xx.xxx.xxx
Comment 5 Hans 2020-11-05 15:30:45 UTC
When doing:

dolphin --new-window sftp://xx@xx.xx.xxx.xxx

It opens window with authentication error and on the command line it says


kf.kio.core: Protocol Class of url QUrl("sftp://xx@xx.xx.xxx.xxx") , isn't ':local', cancelling job.
Comment 6 Harald Sitter 2020-11-06 08:35:26 UTC
I'm 99% certain this is a setup problem.

The reason 

> KIO_SFTP_LOG_VERBOSITY=10 KDE_FORK_SLAVES=1 QT_LOGGING_RULES="log_kio_sftp=true;" dolphin --new-window sftp://xx@xx.xx.xxx.xxx

works is because of KDE_FORK_SLAVES=1 which forces the underlying communication with libssh to start from dolphin directly (thus inheriting the environment which you set via bashrc)

> dolphin --new-window sftp://xx@xx.xx.xxx.xxx

doesn't work because the forking happens from a different process that is started early on in the startup of plasma and as I've mentioned bashrc doesn't play into that. 

Simply put: part of your session doesn't have the env set up correctly because you rely on bashrc but plasma isn't written in bash so it doesn't care what you put there.

You could try putting the ssh-agent stuff into a plasma env script [1] or an Xsession.d script. In any event I encourage you to take this to a support forum to get help on setting up ssh-agent properly for a plasma session.

[1] https://userbase.kde.org/Session_Environment_Variables/en