Last active
April 15, 2017 10:15
-
-
Save sainu/fc5d850ad4fa1ea4b345a61a9126ffa1 to your computer and use it in GitHub Desktop.
Dropbox/.ssh/の鍵ファイルを全て~/.sshにシンボリックリンクを貼るスクリプトを書いた ref: http://qiita.com/saino-katsutoshi/items/216f594468d0b79bdb54
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
$ pwd | |
/path/to/Dropbox/.ssh | |
$ tree . | |
. | |
├── config | |
├── id_hoge_rsa | |
├── id_hoge_rsa.pub | |
└── hoge.pem |
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
$ pwd | |
/path/to/Dropbox/.ssh | |
$ touch setup.sh | |
$ chmod 755 setup.sh | |
$ vim setup.sh |
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
$ pwd | |
/path/to/Dropbox/.ssh | |
$ ./setup.sh |
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
$ cd ~/.ssh | |
$ ls -la | |
lrw-r--r-- 1 me staff 42 4 15 18:24 config@ -> /path/to/Dropbox/.ssh/config | |
$ vim config | |
Host hogehoge | |
...(中略)... |
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/sh | |
files=`find . -maxdepth 1 -type f | sed "s!^.*/!!" | grep -vE "setup.sh|.DS_Store"` | |
for file in $files; do | |
file_path=`pwd`/$file | |
target_dir_path=$HOME/.ssh/ | |
ln -s $file_path $target_dir_path | |
target_file_path=$target_dir_path/$file | |
if [[ $file =~ '.pem' ]]; then | |
chmod -h 400 $target_file_path | |
elif [[ $file =~ '.pub' ]]; then | |
chmod -h 644 $target_file_path | |
elif [[ $file =~ 'config' ]]; then | |
chmod -h 644 $target_file_path | |
else | |
chmod -h 600 $target_file_path | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment