Authenticating with private GitHub repositories in Swift Package Manager using SSH keys

Ian Partridge
Jan 26, 2018 · 2 min read
dependencies: [
.package(url: "https://github.com/user/public-repo.git",
from: "1.0.0")
]

dependencies: [
.package(url: "https://user:password@github.com/user/private-repo.git",
from: "1.0.0")
]

dependencies: [
.package(url: "https://<token>:x-oauth-basic@github.com/user/private-repo.git",
from: "1.0.0")
]

dependencies: [
.package(url: "git@github.com:user/private-repo.git",
from: "1.0.0")
]
$ mkdir .ssh
$ cd .ssh
$ ssh-keygen -b 4096 -t rsa -N "" -f key
Generating public/private rsa key pair.
Your identification has been saved in key.
Your public key has been saved in key.pub.
Host github.com
HostName github.com
User git
IdentityFile ./.ssh/key
Adding a new Deploy Key on GitHub

Bonus

Ian Partridge

Written by

Senior developer in Swift@IBM engineering.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade