LoginSignup
1
3

More than 5 years have passed since last update.

SSHの公開鍵認証

Last updated at Posted at 2015-09-07

参考サイト

秘密鍵と公開鍵を作成

    ssh-keygen -t rsa -b 4096 -C "sample@sample.com"

公開鍵を転送

    scp -P 22 id_rsa.pub user@hostname/.ssh

公開鍵を設定

    mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

権限設定が必要

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 400 ~/.ssh/id_rsa

SSHで公開鍵認証を設定

    sudo vim /etc/ssh/sshd_config
/etc/ssh/sshd_config
    PubkeyAuthentication yes

sshdを再起動

    sudo service sshd restart

公開鍵でSSH接続する

    ssh -i ~/.ssh/id_rsa user@hostname

~/.ssh/id_rsa であれば省略可能

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3