m2.nz/content/posts/ssh_icloud_sync.md

33 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2023-08-16 21:43:54 +00:00
---
2023-08-16 21:48:16 +00:00
title: "iCloud synced SSH configs on macOS"
2023-08-16 21:43:54 +00:00
tags: ["syncing", "config", "ssh"]
2024-01-13 08:08:31 +00:00
date: "2023-08-17"
2023-08-16 21:43:54 +00:00
featuredimagepreview: "/cathacker1.jpg"
---
Maintaining SSH configs can be a pain when you're hopping between multiple devices, even more when syncing apps (Synology/NextCloud/etc) are blocked on some networks/devices.
Make sure you have iCloud Drive enabled and this will symlink your SSH config + key to a folder in iCloud Drive and sync across devices.
2023-08-16 21:49:15 +00:00
The iCloud Drive is located at `~/Library/Mobile Documents/com~apple~CloudDocs`. By putting this file + your config/id_rsa files in here, it will simply symlink them. Warning - the setup script will overwrite existing config/id_rsa files.
2023-08-16 21:43:54 +00:00
2023-08-16 21:49:15 +00:00
Install
```bash
cd ~/Library/Mobile Documents/com~apple~CloudDocs
mkdir macOS && cd macOS
# Create above setup.sh file and copy in your .ssh/config and .ssh/id_rsa keys
./setup.sh
```
setup.sh file
```bash
2023-08-16 21:43:54 +00:00
#!/bin/bash
FOLDER=$(pwd)
ln -sf "$FOLDER/config" ~/.ssh/config
ln -sf "$FOLDER/id_rsa" ~/.ssh/id_rsa
```
2023-08-16 21:49:15 +00:00
2023-08-16 21:43:54 +00:00
Heavily inspired by [This post](https://leihao0.github.io/Sync-macOS-ssh-config-with-iCloud/)