Last active
December 13, 2024 17:55
-
-
Save andsens/2913223 to your computer and use it in GitHub Desktop.
Script that can set up an entire user account with homeshick automatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
# Paste this into ssh | |
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
# When forking, you can get the URL from the raw (<>) button. | |
### Set some command variables depending on whether we are root or not ### | |
# This assumes you use a debian derivate, replace with yum, pacman etc. | |
aptget='sudo apt-get' | |
chsh='sudo chsh' | |
if [ `whoami` = 'root' ]; then | |
aptget='apt-get' | |
chsh='chsh' | |
fi | |
### Install git and some other tools we'd like to use ### | |
$aptget update | |
$aptget install -y zsh tmux vim git | |
### Install homeshick ### | |
git clone git://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick | |
source $HOME/.homesick/repos/homeshick/homeshick.sh | |
### Trust github ### | |
mkdir -p .ssh | |
cat <<EOF >> .ssh/known_hosts | |
|1|6WX8FDwncDK8tfyfkLLbvyepVRw=|15RHFpHg3GHML7eJqvNL/yVYChI= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== | |
|1|cccEMXs7ur0u/JXs4NQYv4A9Xb8=|Pddv+wa776NKeZ4v1yMn1cZWt4s= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== | |
EOF | |
### Set SSH_AUTH_SOCK etc. ### | |
eval `ssh-agent -s` | |
### Deploy private dotfiles ### | |
cat > .dotfiles-deploy-key <<EOF | |
-----BEGIN RSA PRIVATE KEY----- | |
MII............................................................. | |
................................................................ | |
.....................== | |
-----END RSA PRIVATE KEY----- | |
EOF | |
chmod 600 .dotfiles-deploy-key | |
ssh-add .dotfiles-deploy-key | |
homeshick --batch clone [email protected]:username/dotfiles | |
ssh-add -D | |
rm .dotfiles-deploy-key | |
### Clone public repos ### | |
homeshick clone --batch robbyrussell/oh-my-zsh | |
### Link it all to $HOME ### | |
homeshick link --force | |
### Set default shell to your favorite shell ### | |
$chsh --shell /bin/zsh `whoami` | |
echo "Log in again to start your proper shell" |
The private key is supposed to be the deployment key for a private dotfiles repo. The gist itself is supposed to be secret (so that the key is not exposed to the public). Secret gists still have a URL you can access publicly though.
Once you have deployed your dotfiles, it is assumed that you have agent forwarding enabled when pulling.
Did that answer the question?
@andsens if the gist is private, how will you get to it in the first place?
@ngaloppo Private means it's not publicly listed but publicly accessible if you know the URL. This makes it way too dangerous for containing a secret IMHO. It's probably most practical to keep a password-protected deployment key on an external storage.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How exactly are you supposed to put the private key in there? Just commit it to the github repo because the only thing it is exposing is read-only access to an already public repository?