N
N
nepster-web2014-02-11 15:13:07
OpenVZ
nepster-web, 2014-02-11 15:13:07

How to attach a user to an openVZ container?

C created several openVZ containers (101, 102).
On the main server there are 2 users for example test1 and test2.
Tell me, please, how can I make it so that when I log in via ssh to user test1, I get not into his home folder, but into container 101?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Zhivotnev, 2014-02-11
@nepster-web

On the example of 2018 (everything works, checked).
Create scripts like:
(file /usr/bin/vz-2018.sh )

#!/bin/bash
if ; then
    vzctl enter 2018
else 
sudo /usr/bin/vz-2018.sh
fi

chmod +x /usr/bin/vz-2018.sh
Give users sudo to this script:
vz2018 ALL=(ALL) NOPASSWD: /usr/bin/vz-2018.sh
(in /etc/sudoers)
Shell users (in / etc/passwd) write your script to the user instead of /bin/bash (full path to it):
[[email protected] ~]# tail -2 /etc/passwd
vz2018:x:500:500::/home/vz2018:/usr /bin/vz-2018.sh
UPD: just in case, for those who will look for how to start sftp in this scheme - no way. In this case, read here - How to implement authorization forwarding in an openvz container via ssh?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question