SSHD i SSH

From ArchWiki

Jump to: navigation, search
Image:Tango-preferences-desktop-locale.png This page was marked to be translated.
If you understand both "original" and "target" languages of this page, please help complete the translation.
i18n
English
Polski

Contents

SSH

SSH (Secure SHell - bezpieczna powłoka) służy do zdalnego logowania się na inne komputery przez sieć, na przykład Internet. Bezpieczna oznacza, że połączenie jest szyfrowane.
Po zalogowaniu się, możesz robić wszystko to, co możesz robić na normalnej powłoce linuksowej (pamiętając o prawach użytkownika): przeglądać system plików, tworzyć katalogi, przenosić pliki itp. Posługiwanie się SSH jest najlepszą metodą na połączenie się z innym komputerem, jeśli nie przeszkadza ci perspektywa pracy przy czystej konsoli. SSHD (Secure Shell Daemon - serwer bezpiecznej powłoki), oferuje usługi SSH na twojej maszynie.

Jak skonfigurować ssh / sshd na Twoim Archu

Pierwszy krok to oczywiście instalacja oprogramowania. openssh jest wolną/darmową alternatywą dla komercyjnego SSH.

pacman -Sy openssh


Jeśli chcesz, by serwer ssh uruchamiał się wraz ze startem systemu, musisz dodać go do tablicy DAEMONS w pliku /etc/rc.conf:

DAEMONS=(... ... ... ... ... sshd ... ... ...)


Jeżeli chcesz ręcznie uruchomić/zatrzymać/zrestartować serwer ssh, musisz wpisać:

/etc/rc.d/sshd {start|stop|restart}


Aby pozwolić innym na logowanie się do twojego komputera, powinieneś odpowiednio zmodyfikować plik "/etc/hosts.allow":

# Aby pozwolić wszystkim na łączenie się.
sshd: ALL

# Aby pozwolić tylko wybranym adresom IP na łączenie się.
sshd: 192.168.0.1

# Aby pozwolić tylko adresom IP z wybranej klasy na łączenie się.
sshd: 10.0.0.0/255.255.255.0


Teraz powinieneś sprawdzić plik "/etc/hosts.deny" pod kątem poniżej linii i upewnić się, że wygląda tak samo:

ALL: ALL: DENY


To wszystko. Ty możesz logować się na zdalne komputery, a inni mogą logować się do Ciebie.

Konfiguracja

Plik konfiguracyjny znajduje się w etc/ssh/ssh_config, a jego domyślna wersja wygląda tak:

#       $OpenBSD: ssh_config,v 1.19 2003/08/13 08:46:31 markus Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for various options

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
#   EscapeChar ~


Zalecam zmianę linii "Protocol", tak, żeby wyglądała jak to:

Protocol 2


To oznacza, że tylko protokół w wersji 2 będzie używany. Protokół w wersji 1 jest uważany za nieco niebezpieczny. Naturalnie jest także konfiguracja dla serwera SSH. Można znaleźć ją w /etc/ssh/sshd_config, a jej domyślna wersja wygląda tak:

#       $OpenBSD: sshd_config,v 1.69 2004/05/23 23:59:53 dtucker Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#Protocol 2,1
ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh''host''key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh''host''rsa_key
#HostKey /etc/ssh/ssh''host''dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
#obsoletes ~QuietMode and ~FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh''known''hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ~ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, ~PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no

#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression yes
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/lib/ssh/sftp-server


Powinieneś zmienić niektóre linie:

Protocol 2
.
.
.
LoginGraceTime 120
.
.
.
PermitRootLogin no # (wpisz tu "yes", jeśli chcesz, aby możliwym było logowanie się na roota)


Możesz także odkomentować opcję "Banner" i napisać ładną powitalną wiadomość w /etc/issue.

Wskazówka: W moim sshd_config UsePAM jest ustawiony na "yes". Modyfikacja opcji PermitRootLogin na "yes" nie przynosi żadnych zmian. Także UsePAM powinien być ustawiony na "no" albo pam_securetty.so powinien być usunięty z /etc/pam.d/sshd.

(I'm new to Linux, so I hope someone more experienced will fix this Wiki if I'm dead wrong or carelessly irresponsible)

Kontynuuj czytanie na artykule Klucze SSH.

Przydatne adresy i informacje

Personal tools