LoginSignup
3
4

More than 5 years have passed since last update.

自分がサーバを立てるときに最初にする設定(CentOS 7)

Last updated at Posted at 2018-02-12

環境

  • CentOS7
  • シェルはbash
  • 公開鍵認証は設定済みとする

SSHの設定変更

/etc/ssh/sshd_config
Port (ポート番号)
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no

firewalldてSSHポートを変更

sudo firewall-cmd --permanent --service=ssh --add-port=(ポート番号)/tcp
sudo firewall-cmd --permanent --service=ssh --remove-port=22/tcp

色々アップデート

sudo yum -y update

RemiとIUSを追加

sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm

lsコマンドで自動的に-laがつくようにする

/etc/profile.d/colorls.sh
alias ls='ls --color=auto -la' 2>/dev/null

ホスト名を変更

sudo hostnamectl set-hostname (ホスト名)

シェルのプロンプトにFDQNを表示

/etc/profile
if [ $(id -u) -eq 0 ];
then
    export PS1="[\e[35m\u\e[37m@\e[32m\H\e[0m \W]# "
else
    export PS1="[\e[35m\u\e[37m@\e[32m\H\e[0m \W]$ "
fi

他に何かあればアドバイスお願いします

3
4
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
3
4