SSHDの設定方法

更新日:
投稿日:

確認環境

Ubuntu 22.04.3 LTS

設定ファイルのありか

/etc/ssh/sshd_config

公開鍵認証にする

SSHD側に公開鍵を置き、クライアント側からは秘密鍵でアクセスする

  1. sudo nano /etc/ssh/sshd_configで以下の設定に変更

    PubkeyAuthentication yes
    AuthorizedKeysFile      .ssh/authorized_keys
    PasswordAuthentication no
    PermitEmptyPasswords no
    
  2. 鍵置き場を作る

    mkdir ~/.ssh/
    
  3. 公開鍵を書き込む

    echo "公開鍵" > ~/.ssh/authorized_keys
    

備考

/etc/ssh/sshd_configPortもデフォルトの22から別の場所に変えておくとより良い。