Ubuntu
今天談談Ubuntu下面建立用戶以及ssh
Sat Jan 24 17:15:22 PST 2015
添加用戶
直接上碼
useradd <username>
passwd <username>
sudo adduser <username> sudo
mkdir /home/<username>
chown -R <username>:users /home/<username>
ssh
再貼一個one liner
當然了rsa_id必須是 chmod 600
-rw------- 1 user user 526 Dec 25 06:59 identity
-rw-r--r-- 1 user user 330 Dec 25 06:59 identity.pub
cat ~/.ssh/id_rsa.pub | ssh server_alias 'cat >> ~/.ssh/authorized_keys'
PS: server_alias 是從.ssh/config裡面設置好的
如果報錯如下
sh: 1: cannot create /home/<username>/.ssh/authorized_keys: Directory nonexistent
直接這個
cat ~/.ssh/id_rsa.pub | ssh server_alias 'mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && cat >> .ssh/authorized_keys'
Zsh
換shell
sudo apt-get install zsh
sudo chsh -s /usr/bin/zsh