公開鍵ファイルauthorized_keysの設置場所とパーミッション

Linuxで鍵を作成するには、ssh-keygenコマンドを使用します。

で、出来た鍵を置く際のパーミッションで、よくハマる箇所があるのでメモ書き。

ファイル 場所 パーミッション
ユーザールート /user 701
SSHディレクトリ /user/.ssh/ 700
公開鍵 /user/.ssh/authorized_keys 600
公開鍵ファイルの配置とパーミッション
公開鍵ファイルの配置とパーミッション

ここでよく、.sshディレクトリとauthorized_keysファイルのパーミッションを設定したのに、「接続できません」という事態が発生します。
/var/log/secure
でログを見ると、

広告

sshd[8769]: Authentication refused: bad ownership or modes for directory /home/dacelo

ということで、ディレクトリのパーミッションでエラーになっていることが分かりますね。

ユーザールートを701に変更して、これでOKです。

About: dacelo


17 thoughts on “公開鍵ファイルauthorized_keysの設置場所とパーミッション”

  1. Pingback: dacelo
  2. これはまった。ユーザルートは701、~/.sshは700、~/.ssh/authorized_keysは600でssh公開鍵認証。後ろ二つは644,744でも大丈夫そう。

    1. Heya this is somewhat of off topic but I was wanting to know if blogs
      use WYSIWYG editors or if you have to manually code with HTML.
      I’m starting a blog soon but have no coding knowledge so I wanted to
      get advice from someone with experience. Any help would be greatly appreciated!

  3. Hi I am so glad I found your blog page, I really found you by mistake,
    while I was browsing on Bing for something else,
    Anyhow I am here now and would just like to say thank you for a fantastic post and a all round exciting blog (I also love the theme/design), I
    don’t have time to read through it all at the minute but I have bookmarked it and also
    included your RSS feeds, so when I have time I will be back to read a great deal more,
    Please do keep up the superb work.

  4. Hello there I am so glad I found your blog, I really found you by error, while I
    was searching on Digg for something else, Regardless I am
    here now and would just like to say many thanks for a remarkable post and a all round
    enjoyable blog (I also love the theme/design), I don’t
    have time to browse it all at the moment but I have saved it
    and also added your RSS feeds, so when I have
    time I will be back to read a lot more, Please do keep
    up the fantastic job.

Leave a Reply

Your email address will not be published. Required fields are marked *