Skip to content

Commit 5faa363

Browse files
committed
Fix SSH agent on Kubuntu 25.10
1 parent 139bb28 commit 5faa363

File tree

5 files changed

+47
-34
lines changed

5 files changed

+47
-34
lines changed

ssh/pycharm-professional.desktop

100755100644
File mode changed.

ssh/setup_agent.sh

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
#!/usr/bin/env bash
2-
set -eu
2+
# set -eu
3+
set +eu
34

45
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
56
. "${SCRIPT_DIR}/setup_common.sh"
7+
set +eu
68

79
CONF_SCRIPT="${CONF_DIR}/setup_agent.sh"
810

911
if [ ! -f "${CONF_SCRIPT}" ]; then
10-
echo "The agent configuration was not found at: ${CONF_SCRIPT}"
12+
echo "The SSH agent configuration was not found at: ${CONF_SCRIPT}"
1113
exit 1
1214
fi
1315

14-
echo "Configuring SSH agent."
16+
if ! pgrep -u "${USER}" '^ssh-agent$' > /dev/null; then
17+
echo "Warning: No SSH agent seems to be running for the user \"${USER}\"."
18+
fi
19+
20+
echo "Configuring SSH agent using the socket \"${SSH_AUTH_SOCK:-WARNING_NOT_SET}\"."
1521

1622
# Wait for kwallet
1723
if command -v kwallet-query &> /dev/null; then
18-
set +e
24+
# set +e
1925
kwallet-query -l kdewallet > /dev/null
2026
KWALLET_EXIT_CODE=$?
21-
set -e
27+
# set -e
2228
if [ "${KWALLET_EXIT_CODE}" -eq 4 ]; then
2329
echo "Warning: kwallet-query exited with code 4. "
2430
echo "Please create a folder named \"Passwords\" in KDE Wallet with e.g. KWalletManager."
@@ -27,10 +33,17 @@ if command -v kwallet-query &> /dev/null; then
2733
fi
2834
fi
2935

30-
echo "Removing existing identities."
36+
# echo "KDE Wallet is loaded. Waiting for SSH agent to be ready."
37+
# sleep 10
38+
39+
echo "Removing existing identities from the SSH agent."
3140
ssh-add -D
41+
SSH_ADD_EXIT_CODE=$?
42+
if [ "${SSH_ADD_EXIT_CODE}" -ne 0 ]; then
43+
echo "Warning: ssh-add -D exited with code ${SSH_ADD_EXIT_CODE}. Future ssh-add commands may fail as well."
44+
fi
3245

33-
echo "Adding new identities."
46+
echo "Adding new identities to the SSH agent."
3447
# Warning! All added keys that are used for multiple devices
3548
# must be on FIDO2 security keys and require physical confirmation.
3649
# Otherwise the server you connect to can use the SSH keys
@@ -41,13 +54,13 @@ echo "Adding new identities."
4154
LIBTPM2_PKCS11="/usr/lib/x86_64-linux-gnu/pkcs11/libtpm2_pkcs11.so"
4255
LIBTPM2_PKCS11_OLD="/usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1"
4356
if [ -f "${LIBTPM2_PKCS11}" ]; then
44-
set +e
57+
# set +e
4558
ssh-add -s "${LIBTPM2_PKCS11}"
46-
set -e
59+
# set -e
4760
elif [ -f "${LIBTPM2_PKCS11_OLD}" ]; then
48-
set +e
61+
# set +e
4962
ssh-add -s "${LIBTPM2_PKCS11_OLD}"
50-
set -e
63+
# set -e
5164
fi
5265

5366
# The id_rsa is only used for specific purposes
@@ -59,12 +72,12 @@ fi
5972
# https://www.linux.fi/wiki/HST#Ssh_2
6073
OPENSC_PKCS11="/usr/lib/x86_64-linux-gnu/opensc-pkcs11.so"
6174
if [ -f "${OPENSC_PKCS11}" ]; then
62-
set +e
75+
# set +e
6376
ssh-add -s "${OPENSC_PKCS11}"
64-
set -e
77+
# set -e
6578
fi
6679

6780
. "${CONF_SCRIPT}"
6881

69-
echo "Configured identities:"
82+
echo "Configured identities in the SSH agent:"
7083
ssh-add -L

startup/agx-user-pre-startup.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ export SSH_ASKPASS_REQUIRE=prefer
1919
# kwallet-query -l kdewallet > /dev/null
2020
# fi
2121

22-
SSH_AGENT_UPDATED=false
22+
# SSH_AGENT_UPDATED=false
2323
# Pgrep finds regexes, and without the specification for the start and end of the line,
2424
# it could find e.g. the gcr-ssh-agent provided by the package gcr,
2525
# and not start the correct SSH agent.
26-
if ! pgrep -u "${USER}" '^ssh-agent$' > /dev/null; then
26+
# if ! pgrep -u "${USER}" '^ssh-agent$' > /dev/null; then
2727
# echo "SSH agent seems not to be started. Starting, and saving its configuration."
28-
ssh-agent > "${HOME}/.ssh-agent-info"
29-
SSH_AGENT_UPDATED=true
30-
fi
31-
if [ "${SSH_AGENT_UPDATED}" = true ] || [[ "${SSH_AGENT_PID}" == "" ]]; then
32-
# echo "SSH agent configuration seems not to be loaded. Loading."
33-
eval "$(<"${HOME}/.ssh-agent-info")" > /dev/null
34-
fi
28+
# ssh-agent > "${HOME}/.ssh-agent-info"
29+
# SSH_AGENT_UPDATED=true
30+
# fi
31+
# if [ "${SSH_AGENT_UPDATED}" = true ] || [[ "${SSH_AGENT_PID}" == "" ]]; then
32+
# echo "SSH agent configuration seems not to be loaded. Loading."
33+
# eval "$(<"${HOME}/.ssh-agent-info")" > /dev/null
34+
# fi
3535

3636
# echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${LOG_PATH}"
3737
# echo "SSH_AGENT_PID=${SSH_AGENT_PID}" >> "${LOG_PATH}"

startup/agx-user-startup.desktop

100755100644
File mode changed.

startup/agx-user-startup.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ set -u
66
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
77
REPO_DIR="$(dirname "${SCRIPT_DIR}")"
88

9-
if command -v kwallet-query &> /dev/null; then
10-
kwallet-query -l kdewallet > /dev/null
11-
fi
9+
# if command -v kwallet-query &> /dev/null; then
10+
# kwallet-query -l kdewallet > /dev/null
11+
# fi
1212

1313
# Run the pre-startup script again to ensure that the SSH agent is available
1414
. "${SCRIPT_DIR}/agx-user-pre-startup.sh"
@@ -21,7 +21,7 @@ fi
2121

2222
# This should be before other applications just in case, since this configures audio settings for them.
2323
if command -v pactl >/dev/null 2>&1; then
24-
echo "Configuring PipeWire"
24+
echo "Configuring PipeWire."
2525
pactl load-module module-combine-sink
2626
fi
2727

@@ -45,21 +45,21 @@ fi
4545

4646
ACTIVITYWATCH="${HOME}/Downloads/activitywatch/aw-qt"
4747
if [ -f "${ACTIVITYWATCH}" ]; then
48-
echo "Starting ActivityWatch"
48+
echo "Starting ActivityWatch."
4949
"${ACTIVITYWATCH}" &
5050
fi
5151

5252
if command -v flatpak >/dev/null 2>&1; then
53-
echo "Starting Mattermost"
53+
echo "Starting Mattermost."
5454
flatpak run com.mattermost.Desktop --hidden &
55-
echo "Starting Slack"
55+
echo "Starting Slack."
5656
flatpak run com.slack.Slack --startup &
57-
echo "Starting Telegram"
57+
echo "Starting Telegram."
5858
flatpak run org.telegram.desktop -startintray &
5959
fi
6060

6161
if command -v signal-desktop >/dev/null 2>&1; then
62-
echo "Starting Signal"
62+
echo "Starting Signal."
6363
signal-desktop --start-in-tray &
6464
fi
6565

@@ -73,8 +73,8 @@ fi
7373
# fi
7474

7575
if [ "$(hostname)" = "agx-z2e-kubuntu" ]; then
76-
echo "Starting Discord"
76+
echo "Starting Discord."
7777
flatpak run com.discordapp.Discord --start-minimized &
78-
echo "Starting Steam"
78+
echo "Starting Steam."
7979
steam -nochatui -nofriendsui -silent &
8080
fi

0 commit comments

Comments
 (0)