Образовательный проект «SnakeProject» Михаила Козлова

Навигация

⇒ FreeBSD and Nix ⇐

CISCO

Voice(Asterisk\Cisco)

Microsoft

Powershell

Python

SQL\T-SQL

Общая

WEB Разработка

ORACLE SQL \ JAVA

Мото

Стрельба, пневматика, оружие

Саморазвитие и психология


Как исполнить команду\скрипт при аутентификации пользователя по ssh



Как исполнить команду\скрипт при аутентификации пользователя по ssh

К примеру:
Нам нужно при каждом входе пользователя по ssh запускать скрипт

Пользователь ходит по ключу без пароля, его pub ключ в authorized_keys

Находим документацию:

man sshd

AUTHORIZED_KEYS FILE FORMAT
...
command="command"
Specifies that the command is executed whenever this key is used
for authentication.  The command supplied by the user (if any) is
ignored.  The command is run on a pty if the client requests a
pty; otherwise it is run without a tty.  If an 8-bit clean
channel is required, one must not request a pty or should specify
no-pty.  A quote may be included in the command by quoting it
with a backslash.

This option might be useful to restrict certain public keys to
perform just a specific operation.  An example might be a key
that permits remote backups but nothing else.  Note that the
client may specify TCP and/or X11 forwarding unless they are
explicitly prohibited, e.g. using the restrict key option.

The command originally supplied by the client is available in the
SSH_ORIGINAL_COMMAND environment variable.  Note that this option
applies to shell, command or subsystem execution.  Also note that
this command may be superseded by a sshd_config(5) ForceCommand
directive.

If a command is specified and a forced-command is embedded in a
certificate used for authentication, then the certificate will be
accepted only if the two commands are identical.
...

А вот пример запуска скрипта в /root/.ssh/authorized_keys:

Example of /root/.ssh/authorized_keys file:

 


Комментарии пользователей

Эту новость ещё не комментировалиНаписать комментарий
Анонимам нельзя оставоять комментарии, зарегистрируйтесь!

Контакты Группа ВК Сборник материалов по Cisco, Asterisk, Windows Server, Python и Django, SQL и T-SQL, FreeBSD и LinuxКод обмена баннерами Видео к IT статьям на YoutubeВидео на другие темы Смотреть
Мои друзья: Советы, помощь, инструменты для сис.админа, статическая и динамическая маршрутизация, FreeBSD

© Snakeproject.ru создан в 2013 году.
При копировании материала с сайта - оставьте ссылку.

Рейтинг@Mail.ru
Рейтинг@Mail.ru Яндекс.Метрика





Поддержать автора и проект