[memo] init steps for OVH VPS

sudo vi /etc/ssh/sshd_config

# 2022.12.12 RIMMON
Port 2200
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

重啟 sshd
sudo systemctl restart sshd

sudo adduser XXXX

把自己加入 sudo group
sudo vi /etc/group

sudo ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime

sudo echo “Asia/Taipei” > /etc/timezone

修改 hostname
sudo vi /etc/hostname

sudo vi /etc/hosts

開好 VPS 後, OVH 會 email 帳密, 第一次 login 就用那個帳密, 但是好像都沒收到

不過在他的 My profile 下有 emails recevied 裡面有, 不過進 VPS 記得趕快改掉 帳密:


改 /etc/ssh/sshd_config
Port 22
到 22xx 自訂
sudo systemctl restart sshd

ssh -p -p NewPortNumber username@IPv4_of_your_VPS

– add 自己 account
sudo adduser XXXX

  • 在 /etc/group 加
  • sudo:x:27:XXXX

Disabling server access via the root user
– 應該 default 有 diable
– steps:

sudo vi /etc/ssh/sshd_config

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

改好 sudo systemctl restart sshd


more info: https://docs.ovh.com/gb/en/vps/root-password/

Installing Fail2ban

sudo apt install fail2ban

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

sudo nano /etc/fail2ban/jail.local

under [DEFAULT]:

bantime = 10m
maxretry = 5
enabled = false

in the section [sshd]
enabled = true
port = ssh
filter = sshd
maxretry = 3
findtime = 5m
bantime = 30m

sudo service fail2ban restart