SSH passwordless login and sudo user

Password less SSH login to another server can be very useful when you want to configure a remote backup server or when migrating servers. For enabling this you need to have openSSH installed on the server. Here is a tutorial on how to configure password less SSH login to server ‘mars’ from server ‘earth’

1. Login to earth as root.

2. Run the command ssh-keygen -t rsa
If the key already exists you can either go to step 3 or you can generate a new key by overwriting existing key (see image). It would be better to overwrite the existing key if you did not generate it.


public-key

3. Change directory to /root/.ssh/

root@earth:~# cd /root/.ssh/
root@earth:~/.ssh#

4. Copy the contents of the file id_rsa.pub to the directory /root/.ssh/authorized_keys
scp -P id_rsa.pub root@mars_server_IP:/root/.ssh/authorized_keys

5. You will be able to login to the remote server ‘mars’ by typing ssh root@mars_server_IP -p without password now

Creating Sudo user to login as root:

1. Login to server as root

2. Create a new user by using the command

root@server:~# useradd user

3. Assign a password for the user by using the command
root@server:~# passwd user

4. Add the user to the admin group in /etc/groups

root@server:~# vi /etc/groups
admin:x:121:user1,user2

Post to Twitter Tweet This Post

Related posts:

  1. One website in Plesk is asking for user name and password. What is the solution
  2. User stats in directadmin admin area – Solved with a good client’s help :)

Comment Form

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later