Run interactive script at KDE Plasma 5 startup and add keys to ssh agent

Estimated reading time of this article: 2 minutes

How to run an interactive script at KDE Plasma 5 startup?
How to add ssh keys to ssh agent?

KDE Plasma 5 allows to set startup scripts, see How to autostart programs on KDE Plasma 5.

I want to add my ssh keys at every startup to the ssh agent. However, the keys are encrypted and adding them to the agent requires a password. I need to type the password.

Screenshot "KDE Plasma 5 Autostart Script"KDE Plasma 5 Autostart Script

How to do it:

  1. Save the script below into your home directory as
  2. Set the executable bit of the script file, e.g. chmod 755
  3. Install as startup script in KDE
    1. Open KDE System Settings
    2. Click Startup and Shutdown icon
    3. Change to planel Autostart
    4. Click on Add Script… button
    5. Choose
    6. Enable Create as symlink
  4. Reboot and test


# no parameters -> open konsole window
if test $# -eq 0; then
    # wait a little bit
    sleep 15
    # call itself with parameter in a konsole executing bash with command
    konsole --workdir "$HOME" -e bash -c "$HOME/ -i"
# parameters -> execute init steps
    # add id_rsa key to ssh agent if not added yet
    if ! ssh-add -l | grep id_rsa; then
        ssh-add ~/.ssh/id_rsa