-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
50 lines (43 loc) · 1.15 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
echo "${USERNAME} 127.0.0.1:/export/home/${USERNAME}" >> /etc/auto_home
svcadm disable \
svc:/network/rpc/bind:default \
svc:/network/rpc/gss:default \
svc:/network/rpc/smserver:default \
svc:/network/smtp:sendmail
su "${USERNAME}" <<EOF
set -e
mkdir -p /export/home/${USERNAME}/.ssh
chmod 0700 /export/home/${USERNAME}/.ssh
cat /tmp/id_rsa.pub > /export/home/${USERNAME}/.ssh/authorized_keys
rm -f /tmp/id_rsa.pub
chmod 644 /export/home/${USERNAME}/.ssh/authorized_keys
EOF
cat << EOF > /etc/ssh/sshd_config
Protocol 2
Port 22
ListenAddress ::
GatewayPorts no
PrintMotd no
KeepAlive yes
SyslogFacility auth
LogLevel info
StrictModes yes
PermitRootLogin no
MaxAuthTries 5
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
X11Forwarding no
ClientAliveInterval 20
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp internal-sftp
IgnoreRhosts yes
AllowUsers ${USERNAME}
EOF
pkg update --accept