作者:汶水一方
2017.08.13
本文不定期更新。
(1) Enable SSH
Install ssh:
sudo apt-get install openssh-server
重启sshd服务
sudo service ssh restart
(2) 设置静态Static IP
-
sudo nano /etc/NetworkManager/NetworkManager.conf
Change the value of managed fromfalse
totrue
Thenreboot
Linux - Edit :
sudo nano /etc/network/interfaces
Add:
auto eth0
iface eth0 inet static
address 172.26.20.2
gateway 172.26.1.1
netmask 255.255.0.0
dns-nameservers 47.88.13.89
dns-search dev.rokid-inc.com
sudo ifdown -a && sudo ifup -a
(3) 开机启动到命令行 Boot to CLI (not GUI)
- 先备份:
sudo cp -n /etc/default/grub /etc/default/grub.orig
- 然后修改文件:
sudo nano /etc/default/grub
- Comment:
#GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
- Change:
GRUB_CMDLINE_LINUX=”text”
- Uncomment:
GRUB_TERMINAL=console
- Save and Exit
- Comment:
- Update grub via command:
sudo update-grub
- Restart your computer and see the result.
(4) 更新系统组件,安装基本工具
sudo apt-get upgrade
sudo apt-get update
sudo apt-get install -y gawk
sudo apt-get install -y vim
sudo apt-get install -y screen
sudo apt-get install -y nmap
sudo apt-get install -y openssh-server
sudo apt-get install -y curl
sudo apt-get install -y git
sudo apt-get install -y openssh-server vim screen curl git nmap gawk
Note: VI is installed by default. But, if you don't install vim, there will be some problem when using vi to edit files. For example, in Insert mode, pressing arrow keys will generate ABCD characters instead of moving cursors around.
- OPTIONAL: setup vi/vim
sudo vi ~/.vimrc
sudo vi ~/.exrc
For each file above, add set nocompatible
in the file.
(5) 配置公钥认证
- 上传ssh pub-key:在客户端电脑上,执行命令:
ssh-copy-id -i .ssh/id_rsa.pub -p22 yourusername@dest_server_ip
- 打开pubkey验证
sudo nano /etc/ssh/sshd_config
- PubkeyAuthentication 必须为
yes
- PermitRootLogin 设置为
without-password
(见下.) - PasswordAuthentication 必须为
no
- 重启sshd服务
The values of
PermitRootLogin
in your/etc/ssh/sshd_config
no
: you cannot use root to login over ssh at allwithout-password
: root login is allowed but only using a key, not a password.yes
: both key and password are allowed.
sudo /etc/init.d/ssh restart
OR
sudo service sshd restart
//For CentOS 7
systemctl restart sshd.service
(6) 修改SSH登陆时的提示消息
SSH登陆时的欢迎信息在以下2个文件中设置
- Banner will be displayed before the actual login.
- Motd will be displayed after the actual login.
6.1 Banner
- 将要显示的消息文件插入
/etc/issue.net
(for BANNER) - 需要在
/etc/ssh/sshd_config
中取消注释
Banner /etc/issue.net
Note: Text to ASCII GENERATOR
http://patorjk.com/software/taag/
6.2 Motd
- 将要显示的消息文件插入
/etc/motd
(for Motd) - 在
/etc/ssh/sshd_config
中设置PrintMotd yes
可能会出现motd消息打印2次的情况,
PrintMotd yes
改为PrintMotd no
即可解决。详情待考。
(7) 修改hostname 永久生效
sudo nano /etc/hosts
sudo nano /etc/hostname
sudo reboot
(8) 安装、使用screen
sudo apt-get install screen
- 执行
screen
- 然后
repo sync
这样可以关闭terminal,下次再次打开时,可以回到这个session screen -list
screen -r session_id