- Notifications
You must be signed in to change notification settings - Fork0
SSH wrapper to embed SSH key in SSH URL
License
schlomo/ssh-url-with-ssh-key
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
See alsohttp://blog.schlomo.schapiro.org/2017/05/embedding-ssh-key-in-ssh-url.html
ssh-url-with-ssh-key is a wrapper for ssh that extracts a base64 encoded SSH keyfrom the SSHuser~key@host URL and launches SSH with that key.
Set theGIT_SSH environment variable to this script (ssh-url-with-ssh-key)to activate it for your git usage.
ssh-url-with-ssh-key [--help | --create | user~key@host] [command]--create Create a new private and public SSH key. This will print out the private key as you should append it to the SSH user and the public key to add to a remote system.# clone GitHub repo with Deploy Keys$ GIT_SSH=ssh-url-with-ssh-key git clone git~LS0tLS1CRUdJTiBP....SDFWENF324DS=@github.com:user/repo.git# connect to remote SSH server$ ssh-url-with-ssh-key user~LS0tLS1CRUdJTiBP....SDFWENF324DS=@host# create new SSH key pair$ ./ssh-url-with-ssh-key --create schlomo testAppend this base64-encoded private key to the username:~LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUFTZUVqcDRJcFVubGhkTDVEU0VuVkc2aVM0U21Qd3NWR1hNVDhFbDFVZlBvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFbHNRYnZaKzhMLzR3enhYMDlEdGZnZGFTaDVzSFpHUHVUcnVtWXd0UW4yb0txMFVNRmZjaQo4bWFqWWRqclF1YU8vdGN6aCtOWjJ3ZVZiZmY3WE5kQ01RPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=Public Key:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJbEG72fvC/+MM8V9PQ7X4HWkoebB2Rj7k67pmMLUJ9qCqtFDBX3IvJmo2HY60Lmjv7XM4fjWdsHlW33+1zXQjE= schlomo testWritten to supportGitHub Deploy Keys with tools that cannot manageper-repository SSH keys but only offer to store a GitHub URL.
https://hub.docker.com/r/schlomo/ssh-url-with-ssh-key/ is anAlpine based Docker image withssh-url-with-ssh-key andgit,rsync andssh included so that you can simply try it out or use it without installation:
$ docker run -it --rm schlomo/ssh-url-with-ssh-key ssh-url-with-ssh-key --create run in dockerAppend this base64-encoded private key to the username:~LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSVB4S1Fzak9wQ2lTSHVSWkVucWFXYnJUT2hqdW9RSWdtYlRJVzQ2clM4MklvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFZzJ0eEFGVHRBalFSOHpia2g3S1U4Rldpd2NLdXkrNWpRWGVHZ1QrcUZIMk1zOWFBU1M5aAplY3o2UGtyeFZ0ZzdjSTYzV3VKekxjdmduUHBPMUhPOWZRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=Public Key:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBINrcQBU7QI0EfM25IeylPBVosHCrsvuY0F3hoE/qhR9jLPWgEkvYXnM+j5K8VbYO3COt1ricy3L4Jz6TtRzvX0= run in dockerYou can also use it to clone a git repo, for example like this:
$ docker run -it --rm -v $(pwd):/work schlomo/ssh-url-with-ssh-key git clone --depth 1 git~LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUZqWlhTQjBNVDlwNzNoQzJSUXFKU3F6TkZENmkrQ2dabTVvNzE0MGRYZHZvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFMG93bkY4SDVXRHcrVXJoQVZpSnZucGFvMEpzRzlCZW5QK1lCL0hBSWd4dm5ubFUyRytEawpmcDhoUWZoa2Z2YXowMk9YbU1JWWJYVENCVkhTSmoxbUlnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=@github.com:schlomo/demo-data.git fooCloning into 'foo'...The authenticity of host 'github.com (192.30.253.112)' can't be established.RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.remote: Counting objects: 3, done.remote: Compressing objects: 100% (2/2), done.remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0Receiving objects: 100% (3/3), done.$ cd foo$ git statusOn branch masterYour branch is up to date with 'origin/master'.nothing to commit, working tree cleanSeeUsing Kubernetes with Multiple Containers for Initialization and Maintenance for a working example of using this Docker image.
About
SSH wrapper to embed SSH key in SSH URL
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.