日和見軽太郎商会のブログ -8ページ目

日和見軽太郎商会のブログ

今日はヒマだし天気もイイし、クルマでもちょすとしますか!

$ sudo -i

# dnf list | grep jdk

とやると、インストール済みに見えるが・・・・・

 

# java --version
bash: java: command not found...

なので、インストールが必要みたいです。

 

# dnf install -y java-11-openjdk

 

# java --version

openjdk 11.0.17 2022-10-18 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.17.0.8-2.0.1.el9_0) (build 11.0.17+8-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.17.0.8-2.0.1.el9_0) (build 11.0.17+8-LTS, mixed mode, sharing)

でよろしいかと・・・・・

$ sudo -i

# dnf install -y httpd


ポート変更
# mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
# cp /etc/httpd/conf/httpd.conf.original /etc/httpd/conf/httpd.conf
# gedit /etc/httpd/conf/httpd.conf

で「httpd.conf」を以下の様に変更
##Listen 80
Listen ?????

index.html作成
「httpd.conf」の「DocumentRoot」を確認
「DocumentRoot "/var/www/html"」と記述されているので
# gedit /var/www/html/index.html
<html>
    <head>
        <meta charset="utf-8">
        <title>TEST</title>
    </head>
    <body>
        テスト
    </body>
</html>

 

ポート開放
# firewall-cmd --zone=public --add-port=?????/tcp
# firewall-cmd --zone=public --add-port=?????/tcp --permanent
# firewall-cmd --reload

 

サービス起動
# systemctl enable httpd.service

# systemctl start httpd.service

 

既にインストールされているので、認証方法を変更する。

「/etc/ssh/sshd_config」を観ると

「Include /etc/ssh/sshd_config.d/*.conf」と記述されているので

ディレクトリ「/etc/ssh/sshd_config.d/」内に「user.sshd.conf」

を新規作成し、以下を記述して保存

 

PubkeyAuthentication yes
PasswordAuthentication no
Port ?????

 

SSH接続する端末で

「/home/ユーザー」にディレクトリ「.ssh」を作成

$ mkdir -p -m 700 .ssh

 

更に「/home/ユーザー/.ssh」内にファイル「authorized_keys」を作成

$ echo "" > .ssh/authorized_keys

$ sudo chmod 600 .ssh/authorized_keys

 

SSH接続するWindows端末で接続ユーザーの秘密鍵を作成する

コマンドプロンプトを実行

cd .ssh

ssh-keygen -t ed25519 -f id_ed25519

するとディレクトリ「C:\Users\ユーザー名\.ssh」内に

ファイル「id_ed25519」と「id_ed25519.pub」が作成される。

「id_ed25519.pub」をサーバーの接続ユーザーのディレクトリ「/home/ユーザー/.ssh」へコピー

「authorized_keys」へ追加する

$ cat .ssh/id_ed25519.pub >> .ssh/authorized_keys

 

SSHを再起動

$ sudo -i

# service sshd restart

 

ポート確認

$ sudo -i

# firewall-cmd --list-ports

# firewall-cmd --list-all

 

ポート開放

# firewall-cmd --zone=public --add-port=?????/tcp

# firewall-cmd --zone=public --add-port=?????/tcp --permanent

# firewall-cmd --zone=public --add-service=ssh

# firewall-cmd --zone=public --add-service=ssh --permanent

# firewall-cmd --reload

 

余計なポートを閉じる

# firewall-cmd --remove-port=?????/tcp

# firewall-cmd --remove-service=ssh

# firewall-cmd --runtime-to-permanent