差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 | |||
tech:op:ubuntu:install [2018/05/10 16:04:54] 127.0.0.1 外部编辑 |
tech:op:ubuntu:install [2018/07/09 16:30:14] (当前版本) 某喵 |
||
---|---|---|---|
行 3: | 行 3: | ||
## 步骤 | ## 步骤 | ||
- | 1、使用 root 用户 ssh 登录 | + | ### 1、使用 root 用户 ssh 登录 |
- | 2、创建新用户,并给其 `sudo` 权限 | + | ### 2、创建新用户,并给其 `sudo` 权限 |
``` | ``` | ||
adduser newbie | adduser newbie | ||
行 11: | 行 11: | ||
``` | ``` | ||
- | 3、切换到新用户,并配置 ssh key | + | ### 3、切换到新用户,并配置 ssh key |
``` | ``` | ||
su - newbie | su - newbie | ||
行 20: | 行 20: | ||
``` | ``` | ||
- | 4、修改 sshd_config | + | ### 4、修改 sshd_config |
``` | ``` | ||
sudo vi /etc/ssh/sshd_config | sudo vi /etc/ssh/sshd_config | ||
``` | ``` | ||
+ | |||
> Port 4917 # change ssh port(optinal) | > Port 4917 # change ssh port(optinal) | ||
+ | |||
+ | |||
> AllowUsers newbie # restrict only newbie can login through ssh | > AllowUsers newbie # restrict only newbie can login through ssh | ||
+ | |||
``` | ``` | ||
sudo service ssh restart | sudo service ssh restart | ||
``` | ``` | ||
- | 5、简单配置 ufw | + | |
+ | ### 5、简单配置 ufw | ||
``` | ``` | ||
sudo ufw allow {port}/tcp | sudo ufw allow {port}/tcp | ||
行 38: | 行 43: | ||
``` | ``` | ||
- | 6、设置 PS1 | + | ### 6、设置 PS1 |
``` | ``` | ||
txtred='\[\033[0;31m\]' # Red | txtred='\[\033[0;31m\]' # Red | ||
行 47: | 行 52: | ||
``` | ``` | ||
- | 7、更改 hostname | + | ### 7、更改 hostname |
``` | ``` | ||
sudo vi /etc/hostname | sudo vi /etc/hostname | ||
行 53: | 行 58: | ||
``` | ``` | ||
- | 8、更改 ssh welcome message | + | ### 8、更改 ssh welcome message |
> - /etc/motd: The classic, static file. Does not exist anymore in Ubuntu 16.04 LTS, not even as a symbolic link to /var/run/motd. If it is created, however its contents will be printed too. | > - /etc/motd: The classic, static file. Does not exist anymore in Ubuntu 16.04 LTS, not even as a symbolic link to /var/run/motd. If it is created, however its contents will be printed too. | ||
+ | |||
+ | |||
+ | |||
> - /var/run/motd: This was used by Ubuntu’s first implementation. It is not used anymore. It is just ignored by PAM. | > - /var/run/motd: This was used by Ubuntu’s first implementation. It is not used anymore. It is just ignored by PAM. | ||
+ | |||
+ | |||
+ | |||
> - /var/run/motd.dynamic: This is what is shown on login currently. It is updated by /etc/init.d/motd at every boot. It is also updated by PAM by running the scripts in /etc/update-motd.d/, if they exist. | > - /var/run/motd.dynamic: This is what is shown on login currently. It is updated by /etc/init.d/motd at every boot. It is also updated by PAM by running the scripts in /etc/update-motd.d/, if they exist. | ||
+ | |||
+ | |||
+ | |||
> - /etc/motd.tail: The Ubuntu package used to populate /etc/update-motd.d. One of them would cat the contents of this file so it was easy to add static content. That script does not exist in the package anymore, so the file does not have the intended effect. | > - /etc/motd.tail: The Ubuntu package used to populate /etc/update-motd.d. One of them would cat the contents of this file so it was easy to add static content. That script does not exist in the package anymore, so the file does not have the intended effect. | ||