Сервер OpenSSH Сравнение версий

Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
wiki:руководство_по_ubuntu_server:удаленное_администрирование:openssh_server [2012/06/04 18:56]
[Installation]
wiki:руководство_по_ubuntu_server:удаленное_администрирование:openssh_server [2012/12/23 13:19] (текущий)
[Ключи SSH]
Строка 26: Строка 26:
 Пакет openssh-server может быть выбран для установки во время процесса установки Ubuntu Server Edition. Пакет openssh-server может быть выбран для установки во время процесса установки Ubuntu Server Edition.
  
-====Configuration====+====Конфигурация====
  
-You may configure the default behavior of the OpenSSH ​server application, sshd, by editing the file /​etc/​ssh/​sshd_config. ​For information about the configuration directives used in this fileyou may view the appropriate manual page with the following commandissued at a terminal prompt:+Вы можете настроить поведение по умолчанию серверного приложения ​OpenSSH, sshd, редактируя файл ​/​etc/​ssh/​sshd_config. ​Для информации по конфигурационным директивамиспользуемым в этом файлевы можете посмотреть соответствующую страницу руководства,​ задав следующую команду в терминале: 
 +<​code>​man sshd_config</​code>​
  
-man sshd_config+Существует множество директив в конфигурационном файле sshd, управляющих такими вещами,​ как настройки соединений и способы авторизации. Далее примеры конфигурационных директив,​ которые могут быть изменены редактированием файла /etc/ssh/sshd_config.
  
-There are many directives in the sshd configuration file controlling such things as communication settingsand authentication modes. The following are examples of configuration directives that can be changed by editing the /​etc/​ssh/​sshd_config file.+<note tip>​Преждечем редактировать конфигурационный файл, стоит создать копию оригинального файла и защитить его от записи,​ чтобы у вас были оригинальные настройки как справочник,​ который можно использовать повторно при необходимости.
  
-Prior to editing the configuration file, you should make a copy of the original ​file and protect it from writing so you will have the original settings as reference and to reuse as necessary.+Скопируйте файл /​etc/​ssh/​sshd_config и защитите его от записи с помощью следующих команд в терминале:​ 
 +<​code>​sudo cp /​etc/​ssh/​sshd_config /​etc/​ssh/​sshd_config.original 
 +sudo chmod a-w /​etc/​ssh/​sshd_config.original</​code></​note>​
  
-Copy the /​etc/​ssh/​sshd_config file and protect it from writing with the following commandsissued at a terminal prompt:+Далее примеры конфигурационных директивкоторые вы можете изменить:
  
-sudo cp /etc/ssh/​sshd_config ​/etc/ssh/​sshd_config.original +  ** Чтобы установить TCP порт прослушивания для вашего OpenSSH 2222 вместо стандартного 22, измените директиву **Port** таким образом:​ 
-sudo chmod a-w /etc/ssh/​sshd_config.original+<​code>​Port 2222</code> 
 +  ** Чтобы sshd допускал вход с использованием открытых ключей,​ просто добавьте или измените строку:​ 
 +<​code>​PubkeyAuthentication yes</code> 
 +Если строка уже присутствует,​ убедитесь,​ что она не закомментирована. 
 +  ** Чтобы позволить вашему OpenSSH серверу показывать содержимое файла ​/etc/issue.net в качестве шапки пред авторизацией,​ просто добавьте или измените строку:​ 
 +<​code>​Banner ​/etc/issue.net</​code>​
  
-The following are examples of configuration directives you may change:+Все изменения производятся в файле /​etc/​ssh/​sshd_config.
  
-    To set your OpenSSH to listen on TCP port 2222 instead of the default TCP port 22change the Port directive as such:+После изменений в /​etc/​ssh/​sshd_configсохраните файл и перестартуйте серверное приложение sshd для применения изменний,​ используя команду в терминале: 
 +<​code>​sudo /​etc/​init.d/​ssh restart</​code>​
  
-    Port 2222+<note important>​Множество других директив конфигурации sshd доступны для изменения поведения серверного приложения под ваши нужды. Однако учтите,​ что если единственный способ доступа к серверу - это ssh и вы допустили ошибку конфигурации sshd в /​etc/​ssh/​sshd_config,​ вы можете найти свой сервер заблокированным,​ пока его не перезагрузите. В дополнение,​ если неправильная директива настройки воспринялась,​ сервер sshd может отказаться загружаться,​ поэтому будьте очень осторожны,​ когда редактируете этот файл на удаленном сервере. 
 +</​note>​
  
-    To have sshd allow public key-based login credentials,​ simply add or modify the line:+====Ключи SSH====
  
-    PubkeyAuthentication yes+Ключи SSH разрешают авторизацию между двумя узлами без необходимости ввода пароля. Авторизация по ключам SSH использует два ключа: секретный и открытый.
  
-    If the line is already present, then ensure it is not commented out.+Для создания ключей введите в терминале клиента:​ 
 +<​code>​ssh-keygen -t dsa</​code>​
  
-    To make your OpenSSH server display the contents of the /etc/issue.net file as a pre-login bannersimply add or modify the line:+Это сгенерирует ключи использующие метод цифрового алгоритма подписи (DSA). В процессе у вас спросят пароль. Просто нажмите Enter на запрос о создании ключа. 
 +По умолчанию открытый ключ сохраняется в файл ~/.ssh/id_dsa.pubв то время как секретный в ~/​.ssh/​id_dsa. Теперь скопируйте файл id_dsa.pub на удаленный компьютер и добавьте его к ~/​.ssh/​authorized_keys командой: 
 +<​code>​ssh-copy-id username@remotehost</​code>​
  
-    Banner ​/etc/issue.net+В конце дважды проверьте права доступа файла authorized_keys,​ чтобы только авторизованные пользователи имели права на чтение и запись. Если права установлены некорректно,​ измените их: 
 +<​code>​chmod 600 .ssh/authorized_keys<​/code>
  
-    In the /​etc/​ssh/​sshd_config file.+Теперь у вас есть возможность соединиться по SSH с этим узлом без ввода пароля.
  
-After making changes to the /​etc/​ssh/​sshd_config file, save the file, and restart the sshd server application to effect the changes using the following command at a terminal prompt:+====Ссылки====
  
-sudo /etc/init.d/ssh restart +  -- Страница [[https://help.ubuntu.com/community/SSH|SSH на wiki Ubuntu]] 
- +  -- [[http://www.openssh.org/|Сайт OpenSSH]] 
-Many other configuration directives for sshd are available to change the server application'​s behavior to fit your needsBe advised, however, if your only method of access to a server is ssh, and you make a mistake in configuring sshd via the /etc/ssh/​sshd_config file, you may find you are locked out of the server upon restarting it. Additionally,​ if an incorrect configuration directive is supplied, the sshd server may refuse to start, so be extra careful when editing this file on a remote server. +  -- Страница [[https://wiki.ubuntu.com/​AdvancedOpenSSH|продвинутого ​OpenSSH ​на wiki]]
- +
-====SSH Keys==== +
- +
-SSH keys allow authentication between two hosts without the need of a password. SSH key authentication uses two keys, a private key and a public key. +
- +
-To generate the keys, from a terminal prompt enter: +
- +
-ssh-keygen ​-t dsa +
- +
-This will generate the keys using the Digital Signature Algorithm (DSA) method. During the process you will be prompted for a password. Simply hit Enter when prompted to create the key. +
- +
-By default the public key is saved in the file ~/.ssh/id_dsa.pub, while ~/.ssh/id_dsa is the private key. Now copy the id_dsa.pub file to the remote host and append it to ~/​.ssh/​authorized_keys by entering: +
- +
-ssh-copy-id username@remotehost +
- +
-Finally, double check the permissions on the authorized_keys file, only the authenticated user should have read and write permissions. If the permissions are not correct change them by: +
- +
-chmod 600 .ssh/authorized_keys +
- +
-You should now be able to SSH to the host without being prompted for a password. +
- +
-====References==== +
- +
-    Ubuntu Wiki SSH page. +
- +
-    OpenSSH Website +
- +
-    Advanced ​OpenSSH ​Wiki Page+
  
 ---- ----