openSUSE Leap 16

OpenSSH : パスワード認証2025/10/15

 

SSH サーバーを構成し、リモートコンピューターからサーバーに接続して操作できるように設定します。

[1] OpenSSH をインストールします。
dlp:~ #
zypper -n install openssh-server
dlp:~ #
systemctl enable --now sshd
# 現在の設定を確認する

dlp:~ #
sshd -T

port 22
addressfamily any
listenaddress [::]:22
listenaddress 0.0.0.0:22
usepam yes
pamservicename sshd
logingracetime 120
x11displayoffset 10
maxauthtries 6
maxsessions 10
.....
.....
[2] Firewalld を有効にしている場合は、SSH サービスの許可が必要です。SSH は [22/TCP] を使用します。
dlp:~ #
firewall-cmd --add-service=ssh

success
dlp:~ #
firewall-cmd --runtime-to-permanent

success

SSH クライアントの設定 : openSUSE

 

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

[3] SSH クライアントをインストールします。
node01:~ #
zypper -n install openssh-clients
[4] 任意の一般ユーザーで SSH サーバーに接続します。
# ssh [ログインユーザー@ホスト名 または IP アドレス]

suse@node01:~>
ssh suse@dlp.srv.world

The authenticity of host 'dlp.srv.world (10.0.0.30)' can't be established.
ED25519 key fingerprint is SHA256:+ujAkGcRZMk9HrBQxrwNb1bbsuYgW0qLCBU2qRlKQMs.
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.
(suse@dlp.srv.world) Password:
Have a lot of fun...
suse@dlp:~>   # ログインできた
[5] SSH コマンドの引数にコマンドを指定することで、リモートホストで任意のコマンドが実行可能です。
# 例としてリモートホストの /etc/passwd を cat する

suse@node01:~>
ssh suse@dlp.srv.world "cat /etc/passwd"

(suse@dlp.srv.world) Password:
root:x:0:0:root:/root:/bin/bash
tftp:x:499:499:TFTP Account:/srv/tftpboot:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/var/lib/nobody:/usr/sbin/nologin
man:x:13:62:Manual pages viewer:/var/lib/empty:/usr/sbin/nologin
lp:x:498:498:Printing daemon:/var/spool/lpd:/usr/sbin/nologin
messagebus:x:497:482:User for D-Bus:/run/dbus:/usr/sbin/nologin
dnsmasq:x:496:481:dnsmasq:/var/lib/empty:/usr/sbin/nologin
chrony:x:495:480:Chrony Daemon:/var/lib/chrony:/usr/sbin/nologin
.....
.....

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

 

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

[6]
Windows クライアント側で SSH クライアント ソフトウェアを用意します。
一般的には TeraTerm (sourceforge.jp/projects/ttssh2/) や Putty (www.chiark.greenend.org.uk/~sgtatham/putty/) 等が有名です。
当例では Putty を使用します。
Putty をダウンロード/インストールして起動後、以下の画面で、 [Host Name] にサーバーの ホスト名または IP アドレスを入力し [Open] ボタンをクリックします。
[7] ユーザー名とパスワードを入力して認証すると、以下のように openSUSE サーバーに SSH でリモートログインすることができます。

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

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