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.

UbuntuにSSHサーバー設定(ファイアウォール許可設定についても)

Last updated at Posted at 2022-12-17

概要

Ubuntuにリモートデスクトップできる環境を用意してる。
(Windows ⇒ Ubuntuへリモートデスクトップ)

でも、ちょっととしたメンテや確認のたびにリモートデスクトップするの面倒くさい。

SSH接続してコマンドでサクッと作業したい。

やり方

パッケージ一覧更新とインストール

sudo apt update
sudo apt install openssh-server

途中で ↓ 聞かれる。
image.png

起動状態確認

インストールが終了するとSSHサーバーが自動起動する。

sshが起動しているか確認コマンド
sudo systemctl status ssh

起動していれば下記。
image.png

Ubuntu起動と同時にSSHが自動起動する設定になってるか確認

インストールすると、『システム起動と同時にSSHサーバーが自動起動する設定』になる。

Ubuntu起動と同時にsshが自動起動する設定なっているか確認コマンド
systemctl is-enabled ssh

自動起動設定になっていれば下記。
image.png

ファイアウォール設定

ファイアウォールが有効になっている場合、SSH用のポートを解放してあげないと外部から接続できない。

ポート番号22(SSH用のポート番号)を解放するコマンド
sudo ufw allow 22
ファイアウォールの状態表示コマンド(本当に設定が反映されたか確認用)
sudo ufw status

参考サイトさん

バージョン

Ubuntu 20.04.5 LTS
OpenSSH_8.2p1

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?