Skip to content

Instantly share code, notes, and snippets.

@sainu
Last active April 15, 2017 10:15
Show Gist options
  • Save sainu/fc5d850ad4fa1ea4b345a61a9126ffa1 to your computer and use it in GitHub Desktop.
Save sainu/fc5d850ad4fa1ea4b345a61a9126ffa1 to your computer and use it in GitHub Desktop.

Revisions

  1. Saino Katsutoshi revised this gist Apr 15, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ for file in $files; do

    target_file_path=$target_dir_path/$file
    if [[ $file =~ '.pem' ]]; then
    chmod -h 600 $target_file_path
    chmod -h 400 $target_file_path
    elif [[ $file =~ '.pub' ]]; then
    chmod -h 644 $target_file_path
    elif [[ $file =~ 'config' ]]; then
  2. Saino Katsutoshi revised this gist Apr 15, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ for file in $files; do

    target_file_path=$target_dir_path/$file
    if [[ $file =~ '.pem' ]]; then
    chmod -h 400 $target_file_path
    chmod -h 600 $target_file_path
    elif [[ $file =~ '.pub' ]]; then
    chmod -h 644 $target_file_path
    elif [[ $file =~ 'config' ]]; then
  3. Saino Katsutoshi created this gist Apr 15, 2017.
    8 changes: 8 additions & 0 deletions file0.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    $ pwd
    /path/to/Dropbox/.ssh
    $ tree .
    .
    ├── config
    ├── id_hoge_rsa
    ├── id_hoge_rsa.pub
    └── hoge.pem
    5 changes: 5 additions & 0 deletions file1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    $ pwd
    /path/to/Dropbox/.ssh
    $ touch setup.sh
    $ chmod 755 setup.sh
    $ vim setup.sh
    3 changes: 3 additions & 0 deletions file3.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    $ pwd
    /path/to/Dropbox/.ssh
    $ ./setup.sh
    6 changes: 6 additions & 0 deletions file4.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    $ 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
    ...(中略)...
    21 changes: 21 additions & 0 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/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