Skip to content

Commit 90d7c4c

Browse files
committed
document WSL options
Fixes: #339
1 parent a48c0f9 commit 90d7c4c

File tree

3 files changed

+139
-94
lines changed

3 files changed

+139
-94
lines changed
66.9 KB
Loading

doc/usage/options.rst

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ tab.
5252
(default: disabled) Prompts the user for permission every time a client
5353
application requests a key regardless of any other settings.
5454

55+
.. note:: When checked, this overrides the per-entry *Use confirm
56+
constraint* setting. Keys must be unloaded and re-loaded for this
57+
setting to take effect.
58+
5559
- **Show notification whenever key is used by a client program**: (default:
5660
enabled) Shows notification in the taskbar when a client application
5761
requests a key. Notifications only work in Windows.
@@ -60,10 +64,6 @@ tab.
6064
When a client program sends a request, KeePass will display the unlock
6165
dialog before the client request is answered.
6266

63-
.. note:: When checked, this overrides the per-entry *Use confirm
64-
constraint* setting. Keys must be unloaded and re-loaded for this
65-
setting to take effect.
66-
6767
- **Show selection dialog when a client program requests a list of keys**:
6868
(default: disabled) When this option is disabled, KeeAgent will send a
6969
list of all keys to the client program when requested. When enabled,
@@ -73,36 +73,49 @@ tab.
7373
.. tip:: Many SSH servers will refuse to connect if there are more than
7474
6 keys loaded. This option can be used to work around that limitation.
7575

76-
- **Enable agent for Windows OpenSSH (experimental)**: (default: disabled)
76+
- **Enable agent for Windows OpenSSH**: (default: disabled)
7777
Enable an SSH agent socket compatible with the built-in Windows 10 SSH
7878
client.
7979

80-
**Cygwin/MSYS Integration** (Windows only, no effect in *Client* mode)
80+
**Cygwin/MSYS/WSL Integration** (Windows only, no effect in *Client* mode)
8181

8282
- **Create Cygwin compatible socket file (may work with some versions of
8383
MSYS)**: (default: disabled) Creates a file that can be used by Cygwin
8484
programs to access KeeAgent.
8585

86-
- **Path**: The path of the file in the option above.
86+
- **Path**: The path of the file in the option above.
8787

88-
- **Browse...**: Opens a file browser to select the path above.
88+
- **Browse...**: Opens a file browser to select the path above.
8989

9090

9191
- **Create msysGit compatible socket file**: (default: disabled) Creates a
9292
file that can be used by MSYS programs to access KeeAgent.
9393

94-
- **Path**: The path of the file in the option above.
94+
- **Path**: The path of the file in the option above.
9595

96-
- **Browse...**: Opens a file browser to select the path above.
96+
- **Browse...**: Opens a file browser to select the path above.
9797

98-
.. tip:: In order to use the socket file with ssh in Cygwin/MSYS, you need to
98+
- **Create WSL1 compatible socket file**: (default: disabled) Creates a
99+
file that can be used by Windows Susbsystem for Linux V1 programs to access KeeAgent.
100+
101+
- **Path**: The path of the file in the option above.
102+
103+
- **Browse...**: Opens a file browser to select the path above.
104+
105+
Also see the :doc:`tips-and-tricks` page for more info.
106+
107+
.. tip:: In order to use the socket file with ssh in Cygwin/MSYS/WSL1, you need to
99108
set the ``SSH_AUTH_SOCK`` environment variable to the same path::
100109

101110
export SSH_AUTH_SOCK="C:\path\to\socket\file"
102111

112+
For WSL1, the path will look like::
113+
114+
export SSH_AUTH_SOCK="/mnt/c/path/to/socket/file"
115+
103116
You can make this permanent/automatic either by setting this environment
104117
variable in the *Advanced* tab of *System Properties* or in your ``.bashrc``
105-
in Cygwin/MSYS.
118+
in Cygwin/MSYS/WSL.
106119

107120

108121
.. tip:: If KeePass crashes, you will need to manually delete the socket
@@ -113,11 +126,9 @@ tab.
113126
file path options, you will also get an error that the file already
114127
exists.
115128

116-
Also see Cygwin and MSYS on the Tips and Tricks page.
117-
118129
.. danger:: In addition to creating a file, KeeAgent also listens on the
119130
loopback network interface (127.0.0.1) for connections when either of
120-
these options are enabled. The network sockets have no authentication
131+
the Cygwin or MSYS options are enabled. The network sockets have no authentication
121132
mechanism. This is a limitation of the implementation in Cygwin/MSYS.
122133
This means that other users of the same computer can use any keys
123134
loaded in KeeAgent. Therefore, it is not recommended to use this

doc/usage/tips-and-tricks.rst

Lines changed: 113 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,113 @@
1-
===============
2-
Tips and Tricks
3-
===============
4-
5-
Creating URL Overrides to Open a Connection
6-
===========================================
7-
8-
Having lots of SSH keys loaded in KeeAgent can be a problem for many servers.
9-
To work around this, many ssh programs allow you to specify an identity file when
10-
connecting so that it knows which key to use instead of having to try all the
11-
keys that are loaded.
12-
13-
Since SSH keys in KeeAgent are usually saved as attachments embedded in the
14-
database, there is an option in the *Entry Settings* to save the key to an actual
15-
file on disk when the key is loaded in KeeAgent.
16-
17-
.. figure:: images/win10-keepass-entry-keeagent-tab-private-key-file-location.png
18-
:alt: Screenshot of Private Key File Location with "Save attachments to
19-
temporary file when key is loaded" checked
20-
21-
Once you have selected this option, there will be two placeholders available for
22-
use in KeePass.
23-
24-
- ``{KEEAGENT:KEYFILEPATH}`` returns the full path. e.g. ``C:\path\to\keyfile.ppk``
25-
- ``{KEEAGENT:IDENTFILEOPT}`` returns the identity file command line option
26-
that is used by both PuTTY.exe and ssh. e.g. ``-i "C:\path\to\keyfile.ppk"``
27-
28-
You can use these placeholders to create URL overrides. Global overrides are at
29-
*Tools > Options > Integration (tab) > URL Scheme Overrides...* or they can be
30-
specified per-entry on the *Properties* tab of *Entry Settings*.
31-
32-
.. note:: The placeholders also work with the *External File* location in
33-
addition to attachments.
34-
35-
Example:
36-
37-
Open an ssh connection using PuTTY with the username and host specified in
38-
the database entry. The entry must have the Username and URL fields filled
39-
out for this to work.
40-
::
41-
42-
cmd://"C:\Program Files (x86)\PuTTY\PuTTY.exe" -ssh {USERNAME}@{URL:RMVSCM} {KEEAGENT:IDENTFILEOPT}
43-
44-
.. tip:: Read more about the PuTTY command line `here`__. For example, the
45-
``-load`` option is useful to load a saved session associated with the key.
46-
47-
.. __: http://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline
48-
49-
50-
Using KeeAgent on Windows
51-
=========================
52-
53-
54-
Client mode with Pageant
55-
------------------------
56-
57-
KeeAgent (in Agent Mode) is designed to work much like ``ssh-agent`` on Linux/BSD/etc...
58-
Pageant is very similar, but there are some notable differences. Because of the
59-
more limited features of Pageant, it is recommended to run in Agent mode on
60-
Windows instead of using Pageant. However, if you have a good reason to run
61-
KeeAgent in Client Mode along with Pageant, here are some things to be aware of:
62-
63-
- Pageant does not support locking.
64-
- Pageant does not support constraints.
65-
- Pageant does not support ECDSA or Ed25519 keys (except in the development version).
66-
67-
68-
Cygwin and MSYS
69-
---------------
70-
71-
KeeAgent can natively communicate with ssh programs running in Cygwin and
72-
MSYS. It is enabled in the :ref:`global-options` dialog.
73-
74-
There are two implementations of sockets that are found in the various versions
75-
of Cygwin and MSYS. MSYS is really just a fork of Cygwin, so it depends on which
76-
fork the code is based on. So, unless you are using msysGit, try the "Cygwin
77-
socket file" first and if that does not work, try the "msysGit socket file".
78-
In some cases, you may need both enabled to support multiple versions of
79-
Cygwin/MSYS.
1+
===============
2+
Tips and Tricks
3+
===============
4+
5+
Creating URL Overrides to Open a Connection
6+
===========================================
7+
8+
Having lots of SSH keys loaded in KeeAgent can be a problem for many servers.
9+
To work around this, many ssh programs allow you to specify an identity file when
10+
connecting so that it knows which key to use instead of having to try all the
11+
keys that are loaded.
12+
13+
Since SSH keys in KeeAgent are usually saved as attachments embedded in the
14+
database, there is an option in the *Entry Settings* to save the key to an actual
15+
file on disk when the key is loaded in KeeAgent.
16+
17+
.. figure:: images/win10-keepass-entry-keeagent-tab-private-key-file-location.png
18+
:alt: Screenshot of Private Key File Location with "Save attachments to
19+
temporary file when key is loaded" checked
20+
21+
Once you have selected this option, there will be two placeholders available for
22+
use in KeePass.
23+
24+
- ``{KEEAGENT:KEYFILEPATH}`` returns the full path. e.g. ``C:\path\to\keyfile.ppk``
25+
- ``{KEEAGENT:IDENTFILEOPT}`` returns the identity file command line option
26+
that is used by both PuTTY.exe and ssh. e.g. ``-i "C:\path\to\keyfile.ppk"``
27+
28+
You can use these placeholders to create URL overrides. Global overrides are at
29+
*Tools > Options > Integration (tab) > URL Scheme Overrides...* or they can be
30+
specified per-entry on the *Properties* tab of *Entry Settings*.
31+
32+
.. note:: The placeholders also work with the *External File* location in
33+
addition to attachments.
34+
35+
Example:
36+
37+
Open an ssh connection using PuTTY with the username and host specified in
38+
the database entry. The entry must have the Username and URL fields filled
39+
out for this to work.
40+
::
41+
42+
cmd://"C:\Program Files (x86)\PuTTY\PuTTY.exe" -ssh {USERNAME}@{URL:RMVSCM} {KEEAGENT:IDENTFILEOPT}
43+
44+
.. tip:: Read more about the PuTTY command line `here`__. For example, the
45+
``-load`` option is useful to load a saved session associated with the key.
46+
47+
.. __: http://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline
48+
49+
50+
Using KeeAgent on Windows
51+
=========================
52+
53+
54+
Client mode with Pageant
55+
------------------------
56+
57+
KeeAgent (in Agent Mode) is designed to work much like ``ssh-agent`` on Linux/BSD/etc...
58+
Pageant is very similar, but there are some notable differences. Because of the
59+
more limited features of Pageant, it is recommended to run in Agent mode on
60+
Windows instead of using Pageant. However, if you have a good reason to run
61+
KeeAgent in Client Mode along with Pageant, here are some things to be aware of:
62+
63+
- Pageant does not support locking.
64+
- Pageant does not support constraints.
65+
- Pageant does not support ECDSA or Ed25519 keys (except in the development version).
66+
67+
68+
Cygwin and MSYS
69+
---------------
70+
71+
KeeAgent can natively communicate with ssh programs running in Cygwin and
72+
MSYS. It is enabled in the :ref:`global-options` dialog.
73+
74+
There are two implementations of sockets that are found in the various versions
75+
of Cygwin and MSYS. MSYS is really just a fork of Cygwin, so it depends on which
76+
fork the code is based on. So, unless you are using msysGit, try the "Cygwin
77+
socket file" first and if that does not work, try the "msysGit socket file".
78+
In some cases, you may need both enabled to support multiple versions of
79+
Cygwin/MSYS.
80+
81+
82+
Windows OpenSSH
83+
---------------
84+
85+
Although recent versions of Windows ship with OpenSSH out of the box, the
86+
included version is quite out of date. Consider installing the latest version
87+
with ``winget`` or ``choco`` instead or get them straight from the source from the
88+
`GitHub releases <https://github.com/PowerShell/Win32-OpenSSH/releases>`_ page.
89+
90+
These tools are compatible with KeeAgent when **Enable agent for Windows OpenSSH**
91+
is selected in the :ref:`global-options`.
92+
93+
94+
Windows Subsystem for Linux (WSL)
95+
---------------------------------
96+
97+
KeeAgent can be used with `WSL <https://learn.microsoft.com/en-us/windows/wsl/>`_.
98+
99+
For WSL1, simply select **Create WSL1 compatible socket file** in the
100+
:ref:`global-options` and set the ``SSH_AUTH_SOCK`` environment variable
101+
in your WSL1 shell to match.
102+
103+
For WSL2, the environment is more isolated from Windows, so it is not possible
104+
to use the WSL1 socket. Instead, you can use the Windows OpenSSH programs
105+
from inside a WSL2 shell by running ``ssh.exe`` instead of ``ssh``.
106+
107+
.. tip:: You can make a bash alias or symlink to make ``ssh`` an alias for
108+
``ssh.exe``. For example::
109+
110+
sudo ln -s $(which ssh.exe) /usr/local/bin/
111+
112+
Alternately, there are a number of 3rd party solutions for providing a socket
113+
bridge to connect programs inside of WSL2 to an external SSH agent.

0 commit comments

Comments
 (0)