created ssh-agent user systemd unit

ssh-agent is now a user systemd unit and added ./ssh/config
to dotfiles
This commit is contained in:
Jonas Forsberg 2021-11-14 11:41:50 +01:00
parent 6ea988e0a0
commit 3d6de6bf4b
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9
5 changed files with 28 additions and 7 deletions

22
.bashrc
View File

@ -4,6 +4,21 @@ export HISTSIZE=-1
export HISTFILESIZE=-1
export EDITOR="vim"
# used by systemd user unit file ssh-agent in ~/.config/systemd/user/ssh-agent.service
#[Unit]
#Description=SSH key agent
#
#[Service]
#Type=simple
#Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
#ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
#
#[Install]
#WantedBy=default.target
#
#Also add "AddKeysToAgent yes" to ~/.ssh/config
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
test -s ~/.alias && . ~/.alias || true
export PATH=~/bin:~/.local/bin:"$PATH"
type go >/dev/null 2>&1 && export GOPATH=$(go env GOPATH) && export PATH="$PATH":$GOPATH/bin
@ -13,13 +28,6 @@ GPG_TTY=$(tty)
export GPG_TTY
export PWHOME="$HOME/Nextcloud/passwords"
#make sure we only run one ssh-agent
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
ssh-agent > "$XDG_RUNTIME_DIR/ssh-agent.env"
fi
if [[ ! "$SSH_AUTH_SOCK" ]]; then
eval "$(<"$XDG_RUNTIME_DIR/ssh-agent.env")"
fi
if [[ -d "$HOME"/.bash_completions.d ]];then
for file in "$HOME"/.bash_completions.d/*.sh;do

View File

@ -0,0 +1 @@
/home/jonas/.config/systemd/user/ssh-agent.service

View File

@ -0,0 +1,10 @@
[Unit]
Description=SSH key agent
[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
[Install]
WantedBy=default.target

1
.ssh/config Normal file
View File

@ -0,0 +1 @@
Include config.d/*

1
.ssh/config.d/common Normal file
View File

@ -0,0 +1 @@
AddKeysToAgent yes