I need to set up a sftp server, that could use different keys, and use different directories for the same login, depending on the ip used

I got a problem, that I cannot solve myself. I tried to google it, but no satiscactory solution that i could find.
I have a server that is available with let's say 3 different IP addresses (A,B,C), and a user login lets say "user".
I need to setup an sftp server that: when connected with IP A, the SFTP server will announce itself with Key A, when connected with B, announces itself with key B, and so on.
But that is not the end, of the problem, I want to set it up, so when a client tries to connect to "user" with IP A, it would use directory A for accessing user files, when connected with IP B it would use direcotry B, and when connected with IP C, then it would use directory C. I thought of proftpd with sftp mod on, but I got stuck on how to configure directories, that would be accessed with login "user". for eg.
if client tries to access file: user@A:file.dat
real pathname would be directoryA/file.dat
if client tries to access: user@B:file.dat
the real pathname would be directoryB/file.dat
and so on... Now the question is, how to set it up?

0
задан 31 May 2016 в 23:06
2 ответа

Ваш proftpd.conf для этого, я думаю, будет выглядеть следующим образом:

<IfModule mod_sftp.c>
  # Virtual host configuration for server A
  <VirtualHost a.a.a.a>
    Port 22
    SFTPEngine on
    SFTPHostKey /path/to/key/A

    # Restrict members of group A to this directory
    DefaultRoot /path/to/directoryA groupA
  </VirtualHost>

  # Virtual host configuration for server B
  <VirtualHost b.b.b.b>
    Port 22
    SFTPEngine on
    SFTPHostKey /path/to/key/B

    # Restrict members of group A to this directory
    DefaultRoot /path/to/directoryB groupB
  </VirtualHost>

  # Virtual host configuration for server C
  <VirtualHost c.c.c.c>
    Port 22
    SFTPEngine on
    SFTPHostKey /path/to/key/C

    # Restrict members of group C to this directory
    DefaultRoot /path/to/directoryC groupC
  </VirtualHost>
</IfModule>

Ключевым моментом в работе над этим является использование опционального параметра group parameter директивы DefaultRoot (для более подробной информации, я рекомендую Chroot howto).

Имя пользователя "user" будет сконфигурировано немного по-разному для каждого из ваших виртуальных хостов. Для сервера A "user" был бы членом группы A. Для сервера B "user" был бы членом группы B. А для сервера C "user" был бы членом группы C. Если по каким-либо причинам вы не хотите использовать chroot-ограничения, вы можете использовать вместо этого директиву DefaultChdir; это просто помещает аутентифицированного клиента в запрашиваемую директорию в начале его сеанса, после того, как он аутентифицировался.

Надеюсь, это поможет!

.
1
ответ дан 5 December 2019 в 10:23

Вы можете попробовать Sysax Server. Он не бесплатный, но делает свою работу.

-1
ответ дан 5 December 2019 в 10:23

Теги

Похожие вопросы