ssh-agent autostart

ssh-agent autostart


mkdir -p ~/.config/systemd/user/

echo '[Unit]
Description=SSH authentication agent
Wants=dbus.socket
After=dbus.socket
Before=graphical-session-pre.target

[Service]
Type=simple
Environment="DISPLAY=:0" "SSH_AUTH_SOCK=%t/ssh-agent.socket"
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
ExecStartPost=dbus-update-activation-environment --systemd --verbose SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
ExecStop=dbus-update-activation-environment --systemd --verbose SSH_AUTH_SOCK=

[Install]
WantedBy=default.target
'
> ~/.config/systemd/user/ssh-agent.service

### echo 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"' >> ~/.bashrc # or zshrc or similar

mkdir -p ~/.config/environment.d/

echo 'SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"' > ~/.config/environment.d/ssh-auth-sock.conf

systemctl --user enable --now ssh-agent

P.S.: in keepassxc or similar software with integration with ssh-agent may need setup socket path in settings

Содержание