Ubuntu下添加用戶以及ssh

Ubuntu

今天談談Ubuntu下面建立用戶以及ssh

Sat Jan 24 17:15:22 PST 2015

添加用戶

直接上碼

useradd 
passwd 
sudo adduser  sudo 
mkdir /home/
chown -R :users /home/

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//.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

Reference

  1. The Complete Guide to "useradd" Command in Linux - 15 Practical Examples
  2. HOWTO/SSH-with-Keys
  3. scp ssh passwordless
  4. SSH and SCP: Howto, tips & tricks | Linux Academy Blog

你可能感兴趣的:(Ubuntu下添加用戶以及ssh)