Skip to content

Commit

Permalink
Fix SSH agent for Plasma Wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
AgenttiX committed Oct 29, 2024
1 parent 1811b20 commit 9ebe4f4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

if [ -f "${HOME}/.cargo/env" ]; then
. "${HOME}/.cargo/env"
fi

# Pre-startup scripts don't seem to work on Plasma Wayland,
# and therefore the pre-startup script has to be loaded here.
. "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"
19 changes: 16 additions & 3 deletions startup/agx-user-pre-startup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
#!/usr/bin/env bash
set -u
# This should not be set, as it would cause an error when checking if SSH_AGENT_PID is set
# set -u

# https://kcore.org/2022/05/18/ssh-passphrases-kde/

# SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# REPO_DIR="$(dirname "${SCRIPT_DIR}")"
# LOG_PATH="${REPO_DIR}/logs/agx-user-pre-startup.txt"

# echo "Running agx-user-pre-startup.sh at $(date +%F_%H-%M-%S)" >> "${LOG_PATH}"

export SSH_ASKPASS="/usr/bin/ksshaskpass"
export SSH_ASKPASS_REQUIRE=prefer

if ! pgrep -u "${USER}" ssh-agent > /dev/null; then
ssh-agent > ~/.ssh-agent-info
# echo "SSH agent seems not to be started. Starting, and saving its configuration."
ssh-agent > ~/.ssh-agent-info
fi
if [[ "${SSH_AGENT_PID}" == "" ]]; then
eval "$(<~/.ssh-agent-info)"
# echo "SSH agent configuration seems not to be loaded. Loading."
eval "$(<~/.ssh-agent-info)" > /dev/null
fi

# echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${LOG_PATH}"
# echo "SSH_AGENT_PID=${SSH_AGENT_PID}" >> "${LOG_PATH}"
# echo "Finished agx-user-pre-startup.sh at $(date +%F_%H-%M-%S)" >> "${LOG_PATH}"
3 changes: 3 additions & 0 deletions startup/agx-user-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set -u
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
REPO_DIR="$(dirname "${SCRIPT_DIR}")"

# Run the pre-startup script again to ensure that the SSH agent is available
# . "${SCRIPT_DIR}/agx-user-pre-startup.sh"

echo "Starting SSH agent configuration script."
SETUP_AGENT="${REPO_DIR}/ssh/setup_agent.sh"
if [ -f "${SETUP_AGENT}" ]; then
Expand Down
4 changes: 4 additions & 0 deletions zsh/.zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ ZDOTDIR="${HOME}/Git/linux-scripts/zsh"
if [ -f "${HOME}/.cargo/env" ]; then
. "${HOME}/.cargo/env"
fi

# Pre-startup scripts don't seem to work on Plasma Wayland,
# and therefore the pre-startup script has to be loaded here.
. "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"

0 comments on commit 9ebe4f4

Please sign in to comment.