Main issue if you're not using desktop environment, how and when to start "ssh-agent" to store your ssh identity info. In case of full DE you have special daemon, like "gnome-keyring".
On the other hand there are a lot of custom hacks like "how to use ssh-agent with screen" or "using with xinitrc", etc.
Finally i've found that using ssh-agent with systemd is pretty useful. Example from arch wiki is not working for me (i assume for others also). I'm not using separate systemd socket and use additional SuccessExitStatus=2 parameter.
cat << EOF > ~/.config/systemd/user/ssh-agent.service
[Unit]
Description=ssh-agent
[Service]
ExecStart=/usr/bin/ssh-agent -d -a %t/ssh_auth_sock
SuccessExitStatus=2
[Install]
WantedBy=default.target
EOF
systemctl --user enable ssh-agent
systemctl --user start ssh-agent
On the other hand there are a lot of custom hacks like "how to use ssh-agent with screen" or "using with xinitrc", etc.
Finally i've found that using ssh-agent with systemd is pretty useful. Example from arch wiki is not working for me (i assume for others also). I'm not using separate systemd socket and use additional SuccessExitStatus=2 parameter.
1) Create "~/.config/systemd/user/ssh-agent.service"
mkdir -p ~/.config/systemd/usercat << EOF > ~/.config/systemd/user/ssh-agent.service
[Unit]
Description=ssh-agent
[Service]
ExecStart=/usr/bin/ssh-agent -d -a %t/ssh_auth_sock
SuccessExitStatus=2
[Install]
WantedBy=default.target
EOF
2) Start and enable ssh-agent service
systemctl --user daemon-reloadsystemctl --user enable ssh-agent
systemctl --user start ssh-agent
Thanks for your post. I was looking for this.
ОтветитьУдалитьYou're welcome!
ОтветитьУдалитьThis setup is far from complete since it doesn't contain unified way of setting SSH_AGENT_PID and SSH_AUTH_SOCK
ОтветитьУдалитьCorrection: unified way of setting SSH_AGENT_PID and adding keys
Удалить