このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
serverapps:security:ssh [2022/11/06 23:28] hayashi |
serverapps:security:ssh [2024/02/02 12:28] (現在) hayashi [パスワードログインを禁止] |
||
---|---|---|---|
行 1: | 行 1: | ||
====== SSH ====== | ====== SSH ====== | ||
===== ポートフォワード ===== | ===== ポートフォワード ===== | ||
- | + | '' | |
- | < | + | <file> |
Host __r_target_8080 | Host __r_target_8080 | ||
Hostname | Hostname | ||
行 8: | 行 8: | ||
LocalForward | LocalForward | ||
</ | </ | ||
+ | |||
+ | これでssh接続をすると'' | ||
+ | その状態で'' | ||
+ | |||
+ | なお、'' | ||
+ | < | ||
+ | ProxyCommand | ||
+ | </ | ||
+ | |||
+ | ===== ssh-agent ===== | ||
+ | 通常は.bashrcなどに記述するが、tcshなども利用しているので以下のスクリプトを作成 | ||
+ | < | ||
+ | #!/bin/sh | ||
+ | # for ssh-agent | ||
+ | cd ~ | ||
+ | if [ -f ~/ | ||
+ | . ~/ | ||
+ | fi | ||
+ | if [ -z " | ||
+ | / | ||
+ | . ~/ | ||
+ | fi | ||
+ | ssh-add -l > /dev/null 2>&1 || ssh-add | ||
+ | </ | ||
===== rootログインの禁止 ===== | ===== rootログインの禁止 ===== | ||
行 62: | 行 86: | ||
PasswordAuthentication no | PasswordAuthentication no | ||
ChallengeResponseAuthentication no | ChallengeResponseAuthentication no | ||
- | UsePAM no | + | |
FreeBSDは標準でPasswordAuthentication を禁止しているがChallengeResponseAuthentication は許可されているのでこちらも必ず「No」にしておく。 | FreeBSDは標準でPasswordAuthentication を禁止しているがChallengeResponseAuthentication は許可されているのでこちらも必ず「No」にしておく。 | ||
+ | |||
+ | Ubuntuで「/ | ||
+ | |||
+ | <file / | ||
+ | # | ||
+ | PasswordAuthentication no | ||
+ | </ | ||
==== 公開鍵認証をON ==== | ==== 公開鍵認証をON ==== | ||