Skip to content

fix: allow execution of /usr/bin/ssh - #171

Open
hartmutobendorf wants to merge 4 commits into
canonical:mainfrom
hartmutobendorf:main
Open

hartmutobendorf wants to merge 4 commits into
canonical:mainfrom
hartmutobendorf:main

Conversation

@hartmutobendorf

@hartmutobendorf hartmutobendorf commented Aug 21, 2024 •

Copy link
Copy Markdown

Closes #169

added ssh-keys interface
added ssh-public-keys interface
added openssh-client for staging
added bind-file layout for /use/bin/ssh

canonical#170

added ssh-keys interface
added ssh-public-keys interface
added openssh-client for staging
added bind-file layout for /use/bin/ssh
locnnil

This comment was marked as outdated.

@locnnil locnnil left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good! I have one sidenote and one important remark on this:

Sidenote: if you have a non-standard name for your ssh keys (anything other than ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub) you should set the identity file to ~/.ssh/config:

Host <host>
    User <user>
    IdentityFile ~/.ssh/<my_key>

Otherwise, it will fail with:

$ docker --context rem ps
error during connect: Get "http://docker.example.com/v1.52/containers/json": command [ssh -l pi -o ConnectTimeout=30 -T -- <ip-address> docker system dial-stdio] has exited with exit status 255, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
pi@<ip-address>: Permission denied (publickey,password).

But I think it would be important to also support password authentication over ssh, so I left a suggestion on adding the ssh-askpass package.


The important remark: snapd appends /snap/bin to the $PATH on /etc/profile.d/apps-bin-path.sh.

But over ssh, this script isn't sourced, so the $PATH doesn't contain the /snap/bin directory:

ssh pi@buri.local printenv
SHELL=/bin/bash
PWD=/home/pi
LOGNAME=pi
XDG_SESSION_TYPE=tty
MOTD_SHOWN=pam
HOME=/home/pi
LANG=en_GB.UTF-8
SSH_CONNECTION=192.168.68.109 60178 192.168.68.105 22
XDG_SESSION_CLASS=user
USER=pi
SHLVL=0
XDG_SESSION_ID=186
XDG_RUNTIME_DIR=/run/user/1000
SSH_CLIENT=192.168.68.109 60178 22
PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
_=/usr/bin/printenv

There are some workarounds to this like:

  • Option 1:
    You can force the PATH to contain /snap/bin on the remote by setting it in environment.d(5) on /etc/environment, but it's necessary to set the entire path and not append it, like:
$ cat /etc/environment
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin
  • Option 2:
    You can register the docker snap path as an alternative on the remote:
sudo update-alternatives --install /usr/bin/docker docker /snap/bin/docker 50

WARNING: This would definitely conflict if you have docker installed as a deb.

Currently, we list all the available interfaces on our README.md, so please update the list of interfaces and add a note on the usage of the ssh interfaces.

Comment thread snap/snapcraft.yaml
ssh:
plugin: nil
stage-packages:
- openssh-client

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To enable password authentication:

Suggested change
- openssh-client
- openssh-client
- ssh-askpass

@lczyk lczyk changed the title Fix for #169 'snap execution of /usr/bin/ssh fails' fix: allow execution of /usr/bin/ssh Jul 21, 2026
@lczyk lczyk self-assigned this Sep 25, 2026
@lczyk lczyk added Bug confinement something to do with snap confinement labels Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug confinement something to do with snap confinement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snap can not run /usr/bin/ssh => docker cannot use remote context

3 participants