среда, 21 августа 2013 г.

Setting up Ubuntu 12.04 LTS service

Let's talk about Ubuntu 12.04 LTS server setup. It is assumed that you are logged in as root.
  • Add new user group and new user for your regular login
    groupadd admin
    useradd -d /home/john -m -g admin john
  • Delete this user password
    passwd -d john
  • Set new password for this user
    passwd john
  • Set bash as default shell for the user. Edit file /etc/passwd and set following line
    john:x:1000:1000::/home/john:/bin/bash
  • Add this user (all admin group) to sudoers
    visudo
    Add line
    %admin ALL=(ALL) NOPASSWD: ALL
    NOPASSWD here means that when executin sudo system will not ask user password. It is important that this line was one of the last in the sudoers file.
  • Disable root ssh login:
    vim /etc/ssh/sshd_config
    Find line PermitRootLogin and set it to no
    Now you’ll need to restart the sshd service:
    service sshd restart
  • Disable user password login:
    vim /etc/ssh/sshd_config
    Add line
    PasswordAuthentication no
    Add lines:
    RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
    Now you’ll need to restart the sshd service:
    service ssh restart
  • Generate SSH keys for the user. Login as user john and execute following commands:
    ssh-keygen -t rsa
    chmod 700 ~/.ssh
    cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
    chmod 400 ~/.ssh/authorized_keys
  • If using putty for ssh login onto Windows, you should reformat private key with puttygen (open puttygen, load private key, click 'Save private key') and then use this reformatted provate key for putty login

Комментариев нет:

Отправить комментарий