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.

定時帰る術-Linux sshでサーバ管理(ssh、scpコマンド)

Posted at

昔の昔では、telnetもよく使われたが、今完全に消えてしまった。
機器管理もできるし、ポートテストもできるし、便利だと思う。
WindowsもLinux(REHL)もデフォルトでインストールされてないのが少し寂しい

(川口はネットワーク出身で、昔から個別でインストール必要があるのが、いつかからデフォルトパッケージから削除されたのが知りません。)

どうでもいい話は以上で、今日はsshクライアントの話をしようと思う。
(opensshではないよ)

定義ファイル場所

(コマンドのオプションの方が優先)

[root@mgmt ~]# ll /etc/ssh/ssh_config
-rw-r--r--. 1 root root 1770  6月 30  2022 /etc/ssh/ssh_config

ssh

使い方も簡単
(今回はパスワード認証で、よく使われてる証明書認証はサーバ側の方も設定する必要があって、openssh話をする際に、話させてもらう予定)

[root@momo ~]# ssh 192.168.100.6
The authenticity of host '192.168.100.6 (192.168.100.6)' can't be established.
ECDSA key fingerprint is SHA256:o3FAB+htsiuMQHwjyosMrZGGIWabLtLo8rMEVoFP5zU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.6' (ECDSA) to the list of known hosts.
Password:
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last failed login: Wed Nov  1 22:06:07 JST 2023 from 192.168.100.100 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Wed Nov  1 21:57:37 2023 from 192.168.1.67
[root@mgmt ~]#

ポート転送

仕事でもよくポート転送する。
ポート転送することで、何でもできてしまう。(いろんな意味で)
ポート転送もサーバ側で許可(デフォルト)/拒否できるため、これもopenssh話をする際に、話させてもらう予定

scp

sshはサーバのCLI管理用ツールで、scpはssh経由でのファイル転送ツール
これでmomo(ロカール)のsnow-testファイルを192.168.100.6配下に転送できる

[root@momo ~]# touch snow-test
[root@momo ~]# ls
DDNSNow_update.log  anaconda-ks.cfg  snow-test
[root@momo ~]# scp snow-test 192.168.100.6:/var/tmp
Password:
snow-test                                     100%    0     0.0KB/s   00:00

###トラブルシューティング
↓にはよく問題ある箇所
■認証方式
■鍵(あっているか、そもそも持っている、パーミッション(600)は大丈夫か)
■/etc/hosts.allow、/etc/hosts.deny(7系以前のLinux)
■FW
■ping疎通

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?