タグ

2013年4月10日のブックマーク (2件)

  • Java7 体当たり/try-with-resources Statement - 日々常々

    JDK7 を使う準備が出来たので、体当たりします。 Java7 での個人的に嬉しいのが try-with-resources Statement です。AutoCloseable (を実装したクラス)の変数をこの構文で初期化すると、勝手に close してくれるってものです。 ではさらっと使ってみます。 public class TryWithResources { public static void main(String[] args) { try (AutoCloseable imp = new AutoCloseableImpl()) { // New! System.out.println("hoge"); } catch(Exception e) { System.out.println("catch:" + e); } finally { System.out.printl

    Java7 体当たり/try-with-resources Statement - 日々常々
  • 複数の公開鍵を使い分ける - May the Source be with you

    SSH でサーバにリモートログインする際、パスワード認証ではなく公開鍵認証を行っている人も多いかと思います。自宅内では同じ鍵を使い回していたのですが、仕事の都合で新しい鍵を作ることになりました。例によって備忘録です。 キーを作るのはこんな感じ。 $ ssh-keygen -C hoge@fuga.com -f ~/.ssh/id_rsa.hogeログインする時は -i オプションで鍵ファイルを指定することで、鍵を使い分けることができます。 $ ssh -i ~/.ssh/id_rsa.hoge hoge@fuga.com~/.ssh/config に使用する鍵を列挙しておけば、鍵ファイルを勝手に探してくれます。ファイルの中身はこんな感じで。 IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/id_rsa.hoge IdentityFile ~/.

    複数の公開鍵を使い分ける - May the Source be with you
    yukung
    yukung 2013/04/10
    "~/.ssh/config に使用する鍵を列挙しておけば、鍵ファイルを勝手に探してくれます。" これは知らなんだ