重裝後的備忘
安裝 NTP
1234567
apt-get install ntp ntpdate#vim etc/ntp.confserver time.stdtime.gov.twserver clock.stdtime.gov.twntpdate time.stdtime.gov.tw
更改時區
12
dpkg-reconfigure tzdatadate #檢查
開啟網卡、DHCP
1234
ifconfig -aifconfig eth0 updhclient eth0ifconfig #檢查
設定新使用者
kali 預設 root 無法用於 ssh 登入
123456
useradd -m usern #新增使用者 -m 的意思是創建用戶的主目錄passwd usern #設置密碼usermod -a -G sudo usern #. 為添加的用戶賦予權限 (-a 添加 ;-G 群組) ,如果沒有這一步,我們創建的用戶只有瀏覽的權限而沒有修改等其它的特殊權限chsh -s /bin/bash usern #將用戶 usern 的默認外殼改成 bash ,還可以改其它的,比如 csh 、zsh、fish 等,如果沒有什麼特別的用途,一般用 bashid usern #檢查userdel usern #刪除
安裝 SSH Server
檢查有無安裝
apt list openssh-server
如果看到如 [installed] 字樣,代表有裝過。
如果沒有,執行下列步驟:
先做更新再安裝
apt-get update
apt install openssh-server
Kali 帶有預設的 SSH 密鑰,為了安全先備份再生成新密鑰:
123
mkdir /etc/ssh/default_keysmv /etc/ssh/ssh_host_* /etc/ssh/default_keys/dpkg-reconfigure openssh-server #生成新密鑰
如果只是計劃簡單使用 SSH,則默認值可能沒問題。如果你認為你會使用它一段時間,我會建議至少啟用公鑰認證:
編輯 SSH Server 設定
vim /etc/ssh/sshd_config
1
PasswordAuthentication no #禁用密碼認證
您也可以在此處允許 root 用戶登錄,但應考慮創建非特權用戶帳戶。
與 SSH 相關的單元是 ssh.service 和 ssh.socket。在基本級別上,service 控制進程,socket 控製文件系統或網絡套接字。如果您只需要暫時啟動 SSH 服務,建議使用 ssh.socket:
12
systemctl start ssh.socket #暫時啟動 SSH 服務systemctl stop ssh.socket #停止
12345
systemctl enable ssh.service #永久啟用 SSH 服務systemctl start ssh.service #立即使用SSH而無需重新啟動systemctl status ssh.service #檢查 SSH 服務狀態systemctl stop ssh.service #關閉服務systemctl disable ssh.service #禁用服務
Powerline
來源
Powerline 是一個 Vim 狀態列與 Shell 命令提示字元的外掛,除了 Vim 之外也可以用於各種 Shell 與應用程式中,如 zsh、bash、tmux、IPython、Awesome 與 Qtile。
Powerline 是使用 Python 所開發的一個外掛小工具,支援各種常見的 Shell 與應用程式,可以產生非常漂亮的提示字串與狀態列文字,讓終端機的文字看起來更舒服。
自動安裝
1
sudo apt-get install powerline
使用
在 Bash Shell 中使用,只要在 ~/.bashrc 中加入下面這段程式碼後重開即可
1234
POWERLINE_SCRIPT=/usr/share/powerline/bindings/bash/powerline.shif [ -f $POWERLINE_SCRIPT ]; thensource $POWERLINE_SCRIPTfi
若要在 Vim 的狀態列中使用 Powerline,則在 ~/.vimrc 中加入這幾行:1
12345
set laststatus=2set t_Co=256python3 from powerline.vim import setup as powerline_setuppython3 powerline_setup()python3 del powerline_setup