Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two virtual machines VM1(Ubuntu) & VM2(Debian). VM1 has a single user "admin" & VM2 has two users "test1" & "test2". What I want is that only test1 was able to access VM1 through ssh whereas test2 user should not able to access VM1 through ssh.

i.e if I logged in as test1 user & type ssh admin@VM1host.com than remote machine should allow this user to access the machine(VM1) whereas if I'm logged in as test2 & try the same command than the remote machine(VM1) should restrict ssh access for this user.

share|improve this question
up vote -1 down vote accepted

You can restrict ssh access to ssh keys only (disable password login with PasswordAuthentication no) and only allow the key from test1 user account in ~admin/.ssh/authorized_keys on the VM1 machine.

Obs: the public key you will need to allow in admin@VM1 will be the public key /home/test1/.ssh/id_rsa.pub on VM2 machine (or something similar if you use rsa keys).

share|improve this answer

You have to set the AllowUsers (or AllowGroups) properties in the /etc/ssh/sshd_config:

AllowUsers test1

man of sshd_config

share|improve this answer
1  
AllowUsers only works for the users present on VM1 machine i.e only allow ssh-login as admin user.However through AllowUsers host can be checked i.e admin@host.So it will check the host to be allowed.But in my case Both the users are on same machine i.e VM2 ,so same host. – saurabh Jun 6 '14 at 11:22
    
Now I understand. Maybe that is not possibile with ssh client. Try to read deeply the man of ssh_config file: openssh.com/cgi-bin/man.cgi?query=ssh_config – Marco Merli Jun 6 '14 at 12:31
    
It is possible to do so requiring ssh keys to login (disable password login and only allow keys for ssh). – laurent Jun 13 '14 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .