Задачи
- Предоставить возможность перезагружать сервер пользователям из под Windows по одному нажатию без ввода пароля и комманд
- Ограничить учетку из под которой происходит перезагрузка
1. Устанавливаем lshell
cd /usr/ports/shells/lshell
make
make install
2. Приводим файл /usr/local/etc/lshell.conf к виду (разрешаем только выполнение комманды shutdown)
# lshell.py configuration file
#
# $Id: lshell.conf,v 1.24 2010/04/17 23:14:58 ghantoos Exp $
[global]
## log directory (default /var/log/lshell/ )
logpath : /var/log/lshell/
## set log level to 0, 1, 2 or 3 (0: no logs, 1: least verbose)
loglevel : 2
## configure log file name (default is %u i.e. username.log)
logfilename : %y%m%d-%u
[default]
## a list of the allowed commands or 'all' to allow all commands in user's PATH
allowed : ['shutdown']
## a list of forbidden character or commands
forbidden : ['su','ls','cd','cd','rm','chmod','[',';', '&', '|','`','>','<', '$(', '${']
## a list of allowed command to use with sudo(8)
#sudo_commands : ['reboot']
## number of warnings when user enters a forbidden value before getting
## exited from lshell
warning_counter : 3
## command aliases list (similar to bash\xe2\x80\x99s alias directive)
#aliases : {'ll':'ls -l', 'vi':'vim'}
## introduction text to print (when entering lshell)
#intro : "== My personal intro ==\nWelcome to lshell\nType '?' or 'hel
p' to get the list of allowed commands"
## a value in seconds for the session timer
#timer : 5
## list of path to restrict the user "geographicaly"
#path : ['/home/bla/','/etc']
## set the home folder of your user. If not specified the home_path is set to
## the $HOME environment variable
#home_path : '/home/bla/'
## update the environment variable $PATH of the user
#env_path : ':/usr/local/bin:/usr/sbin'
## allow or forbid the use of scp (set to 1 or 0)
scp : 0
## forbid scp upload
scp_upload : 0
## forbid scp download
scp_download : 0
## allow of forbid the use of sftp (set to 1 or 0)
sftp : 1
## list of command allowed to execute over ssh (e.g. rsync, rdiff-backup, etc.)
overssh : ['shutdown']
## logging strictness. If set to 1, any unknown command is considered as
## forbidden, and user's warning counter is decreased. If set to 0, command is
## considered as unknown, and user is only warned (i.e. *** unknown synthax)
#strict : 1
## force files sent through scp to a specific directory
#scpforce : '/home/bla/uploads/'
## history file maximum size
#history_size : 100
## set history file name (default is /home/%u/.lhistory)
#history_file : "/home/%u/.lshell_history"
3. Создаем пользователя
adduser
Name: rebooter
4. Добавляем его в группу operator
pw usermod rebooter -G operator
5. Меняем шелл пользователя на lshell
chpass rebooter
изменяем строчку на
Shell: /usr/local/bin/lshell
6. В Windows делаем файл rebooter.bat
а в нем строки
@echo off
plink.exe -ssh 10.10.30.75 -l rebooter -pw mypass shutdown -r now
pause
в папку с этим файлом кладем plink.exe
(берем его здесь http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html )
7. При первом запуске plink попросить нажать y чтобы добавить открытый ключ потом просить не будет
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий