# Persistent SSH and Terminal configs Your SSH keys and configuration files (like `.ssh` or `.gitconfig`) are typically saved in the home directory. However, since the home directory is **ephemeral**, any changes you make to these files disappear when your container restarts. The most common use case for this is **Git integration**, and the [remote access via SSH](./remote_ssh_access.md). By persisting your SSH keys, you can upload a single public key to GitHub (or similar hosting) and maintain access across container restarts or when launching new containers. Since your cloned projects are already stored in your **personal storage folders**, persisting your identity allows you to push and pull changes seamlessly without re-authenticating every session. To maintain persistent changes, we rely on the [**persistence pattern**](./persistence.md): store the actual data in your persistent volume and link it to the system. ## The Problem: Ephemeral `.ssh` The system expects your SSH keys to be in `~/.ssh`. If you create them there, they are lost on restart. This is important if you are working for example with git repositories, and you want to use a consistent ssh key for your work in SciServer. ## The Solution: The Symlink Pattern The most efficient way to handle this is to store your `.ssh` directory in persistent storage and create a **symbolic link** (symlink) that points the system to that location. ### 1. Create your keys normally If you don't have SSH keys yet, generate them in your home directory first. This ensures that the `~/.ssh` folder is created with the correct system permissions automatically. ```bash ssh-keygen -t ed25519 -C "$SCISERVER_USER_NAME@sciserver_container" ``` You can already use this key `~/.ssh/id_ed25519.pub` your git hosting provider (e.g. Github, [MPCDF Gitlab](https://gitlab.mpcdf.mpg.de), [Codeberg.org](https://codeberg.org), etc) ### 2. Move keys to Persistent Storage Now that the folder exists with the correct permissions (or if you already had existing keys), move it to your persistent storage: ```bash mv ~/.ssh ~/workspace/Storage/$SCISERVER_USER_NAME/persistent/.ssh ``` ### 2. Manually Link Them (Temporary Fix) You can link them manually for your current session: ```bash ln -s ~/workspace/Storage/$SCISERVER_USER_NAME/persistent/.ssh ~/.ssh ``` ### 3. Automate the Link (Permanent Fix) To avoid doing this every time you launch a container, add the linking logic to your **Automation Engine** ( See [Shell Automation](./shell_automation.md) ). Add this to your `$HOME/workspace/Storage/$SCISERVER_USER_NAME/persistent/.bashrc` file: ```bash # Automatically restore SSH symlink if persistent storage exists if [ -d "$HOME/workspace/Storage/$SCISERVER_USER_NAME/persistent/.ssh" ]; then ln -s "$HOME/workspace/Storage/$SCISERVER_USER_NAME/persistent/.ssh" "$HOME/.ssh" 2>/dev/null fi ``` Now, every time you start a new container, your SSH keys will be automatically "restored" to the expected location. --- ## Other Identity Files You can use this same pattern for other configuration files: - **Git Config:** Move `.gitconfig` to `~/workspace/Storage/$SCISERVER_USER/persistent/` and link it in your `.bashrc`.