LoginSignup
0
1

More than 5 years have passed since last update.

【CentOS7】サーバの初期設定

Last updated at Posted at 2017-11-19

はじめに

サーバを作成後に毎回行っている作業です。

前提

作業ユーザを作成

# adduser [username]

作業ユーザをsudoersに追加

# visudo
/etc/sudoers
## Same thing without a password
%[username]  ALL=(ALL)   NOPASSWD: ALL

作業ユーザに公開鍵を設置

公開鍵はrootユーザのものを流用する

# su - [username]
$ mkdir .ssh
$ chmod 700 .ssh/
$ sudo cp /root/.ssh/authorized_keys .ssh/
$ sudo chown [username]:[username] .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys 

rootユーザのログインを制限

ログインを制限する前に作業ユーザでログインできるか確認する

# vim /etc/ssh/sshd_config
/etc/ssh/sshd_config
#PermitRootLogin yes  ->  PermitRootLogin no

変更を反映させるためsshdを再起動する

# systemctl restart sshd.service
0
1
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
1