0

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.

2 Answers 2

0

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

1

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

AllowUsers test1

man of sshd_config

3
  • 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, 2014 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 Jun 6, 2014 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, 2014 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.