0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

teraterm: dockerでsshサーバを立ててテストを行う

Last updated at Posted at 2024-05-06

はじめに:teratermとは

teratermとは、Windows向けのターミナルソフト。
WSL2が普及する以前、Windowsの場合はこのツールがSSHターミナルソフトの主流だった。

なぜ、sshサーバを立てなければならないのか

  • teratermは通常、単体テストを行えない。なぜなら独自のTera Term Language (TTL)を使用しているため
    • teraterm対応の自動テストフレームワークがないから、ユニットテストを行えない
    • 一方、サーバがなければ結合テストができない
    • 複数人で使用する環境には、(テスト環境といえども)未テストの資材を持ち込みたくない

では、どうするか(WSL2+dockerでサーバを立てればよい)

もっとも手軽な解決策として、dockerでサーバを立てる方法が挙げられる

sshサーバの立ち上げ

今回は、linuxserver/openssh-serverイメージを選定した。

teratermのテストを目的としているため、volumeを使用しない。したがって、データは永続化されない。

compose.yml
services:
  openssh-server:
    image: linuxserver/openssh-server:version-9.6_p1-r0
    container_name: openssh-server
    hostname: openssh-server #optional
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Tokyo
      - PASSWORD_ACCESS=true 
      - USER_PASSWORD=**password**
      - USER_NAME=**user**
      - LOG_STDOUT= #optional
    ports:
      - 2222:2222
    restart: unless-stopped

起動はいつも通り

docker compose up -d

起動後のアクセス確認

docker composeの場合(同一ネットワーク)

テストには、arukiidou/sshpassイメージを使用する。

compose.yml
services:
  openssh-server:
    #(略)
  openssh-sshpass:
    image: arukiidou/sshpass:1.10-alpine3.19
    container_name: openssh-sshpass
    tty: true
sshpass -p '**password**' ssh -o StrictHostKeyChecking=no -p 2222 **user**@openssh-server

WSL2(コンテナ外、同一ホスト)の場合

sshpass -p '**password**' ssh -o StrictHostKeyChecking=no -p 2222 **user**@localhost

teratermの場合

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?