FreeBSD 15

OpenSSH : パスワード認証2025/12/18

 

SSH サーバーを構成し、リモート端末からサーバーに接続して操作できるようにします。なお、SSH は 22/TCP を使用します。

[1] OpenSSH サーバーはデフォルトでパスワード認証方式でのログインは可能となっているため、サービスが有効になっていればリモートログインすることができます。
# sshd サービスの状態確認

root@dlp:~ #
grep sshd /etc/rc.conf

sshd_enable="YES"
root@dlp:~ #
service sshd status

sshd is running as pid 1264.
# もし sshd_enable="NO" になっている場合は YES に変更してサービス起動

root@dlp:~ #
service sshd start

SSH クライアント : FreeBSD

 

SSH クライアントからの接続方法です。

[2] 任意の一般ユーザーで SSH サーバーに接続します。
# ssh [ログインユーザー@ホスト名 または IP アドレス]

freebsd@node01:~ $
ssh freebsd@dlp.srv.world

The authenticity of host 'dlp.srv.world (10.0.0.30)' can't be established.
ED25519 key fingerprint is SHA256:sMH9Z+x8vA09rKvM/j7rZub+I0m2josPhCIVogXQzH4.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'dlp.srv.world' (ED25519) to the list of known hosts.
(freebsd@dlp.srv.world) Password for freebsd@dlp.srv.world:
Last login: Thu Dec 18 08:35:23 2025 from 10.0.0.5
FreeBSD 15.0-RELEASE (GENERIC) releng/15.0-n280995-7aedc8de6446

Welcome to FreeBSD!
.....
.....
freebsd@dlp:~ $    
# ログインできた

[3] SSH コマンドの引数にコマンドを指定することで、リモートホストで任意のコマンドが実行可能です。
# 例としてリモートホストの [/etc/passwd] を [cat] する

freebsd@node01:~ $
ssh freebsd@dlp.srv.world "cat /etc/passwd"

(freebsd@dlp.srv.world) Password for freebsd@dlp.srv.world:
root:*:0:0:Charlie &:/root:/bin/sh
toor:*:0:0:Bourne-again Superuser:/root:
daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin
operator:*:2:5:System &:/:/usr/sbin/nologin
bin:*:3:7:Binaries Commands and Source:/:/usr/sbin/nologin
tty:*:4:65533:Tty Sandbox:/:/usr/sbin/nologin
.....
.....

SSH クライアントの設定 : Windows #1

 

SSH クライアントの設定です。Windows を例にします。

[4]

Windows クライアント側で SSH で接続可能なソフトウェアを用意します。
当例では Putty を使用します。

Putty を上記サイトからダウンロード/インストールして起動したら、以下のような画面になるので、 Hostname にサーバーの ホスト名または IP アドレスを入力し [Open] をクリックして接続します。
[5] ユーザー名とパスワードを入力して認証すると、以下のように FreeBSD サーバーにリモートログインすることができます。

SSH クライアントの設定 : Windows #2

[6] Windows には OpenSSH クライアントが標準で実装されています。
これにより、Putty 等の SSH クライアントを用意しなくとも、Windows の標準機能で SSH サーバーへ接続可能です。
関連コンテンツ