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 3 years have passed since last update.

centos Ansible ssh有効化

Last updated at Posted at 2020-07-26

・keypair作成(client)
$ssh-keygen -t rsa -b 4096

$ mkdir ~/.ssh
$ chmod -R 700 ~/.ssh
$ vi ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

・sshd_config設定
$ sudo vi /etc/ssh/sshd_config

Port 49152 #デフォルト:#Port 22
PermitRootLogin no #デフォルト:PermitRootLogin yes
PubkeyAuthentication yes #デフォルト:#PubkeyAuthentication yes
PasswordAuthentication no #デフォルト:PasswordAuthentication yes

・firewalld穴空け
$ sudo firewall-cmd --add-port=49152/tcp --permanent
$ sudo firewall-cmd --reload
$ sudo firewall-cmd --list-port
22/tcp

・service再起動
$ sudo systemctl restart sshd
$ sudo systemctl status sshd


$ sudo dnf install -y policycoreutils-python-utils
$ sudo semanage port --add --type ssh_port_t --proto tcp 49152
$ sudo semanage port --list | grep ssh
ssh_port_t tcp 49152, 22
$ sudo systemctl restart sshd
$ sudo systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat yyyy-MM-dd hh:flag_mm:ss JST; ●h ●min ago

0
0
1

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?