Friday, September 18, 2015

Configuring new VPS.

Login to the server (via ssh).

$ ssh root@*.*.*.*
root@ubuntu:~# w
I want to create another user.
root@ubuntu:~# adduser youri
Make sure I can login as youri. 
 $ ssh youri@*.*.*.*

Escalate to root:
youri@ubuntu:~$ su root
I want to disable root ssh login.
#PermitRootLogin no in /etc/ssh/sshd_config and service ssh restart
Logging as root says: Permission denied, please try again
Now I want to transfer my keys.
 $ ssh-copy-id  youri@*.*.*.*
spits out

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
but after ssh-add ~/.ssh/id_rsa it worked and copied the key.

Ssh in again and passwordless login is working. 

Now I want to disable password logins altogether.
PasswordAuthentication no in /etc/ssh/sshd_config and service ssh restart
Add my user to sudoers:
root@ubuntu:/home/youri# usermod -a -G sudo youri