Служба RHEL 7 SSH СТАРТ СТОП ПЕРЕЗАПУСК

Мне нужен ответ, указанный в первом предложении, когда я пытаюсь использовать приведенный ниже фрагмент в моем.bashrc.

alias ls='\ls -F --color=auto --show-control-chars'
alias ll='ls -ahl'
function lf_macro() {
    local CMD=${1:-ls} DIR=${2:-.};
    $CMD $(find $DIR -maxdepth 1 -type f);
}
function lf() { lf_macro ll "$1"; }
function lsf() { lf_macro ls "$1"; }     # list all file, no directories

после unalias -a; source ~/.bashrcпытаюсь выполнить lfи lsf,

$ lf
-bash: ll: command not found

$ lsf
./file1./file2./script.sh...     # no color, no control-chars

$ ls $(find -maxdepth 1 -type f)
./file1./file2./script.sh*...

кажется очевидным, что псевдонимы расширяются при определении функции, а не при выполнении функции, поскольку:

  • , когда я выполняю lf, ошибка -bash: ll: command not foundи
  • когда я выполняю lsf, /usr/bin/lsиспользуется, а не форма псевдонима, без цвета выделение и отсутствие управляющих символов после исполняемого файла.
1
07.08.2019, 17:26
3 ответа

Невозможно включить этот тип вывода для systemd:https://bugzilla.redhat.com/show_bug.cgi?id=1148571

Тем не менее, он обязательно сообщит вам о сбое и о том, как вы можете узнать больше о причинах сбоя.

0
28.01.2020, 00:04

Еще в Redhat 5 (и 6 )это был способ INIT с использованием /etc/init.d. Redhat 7 использует systemd , и вы можете провести остаток дня в Интернете и читать статьи, сравнивая их различия, плюсы, минусы и так далее.

ты делал

/etc/init.d/sshd status
/etc/init.d/sshd start
/etc/init.d/sshd stop
/etc/init.d/sshd restart

or you may be more familiar with     service sshd <start|stop|restart|status>

в RHEL 7 вы делаете

systemctl status sshd
systemctl start sshd
systemctl stop sshd
systemctl restart sshd

service sshd <start|stop|restart|status> will also work but you'll get an info statement saying "redirecting to /bin/systemctl"

выполнение systemctl status sshdможет дать вам хорошее представление о том, что неправильно; а также поиск в /var/log/messagesсообщений об ошибках.

в RHEL 7.x (и многих других linux )SSHd на сервере настраивается в файле /etc/ssh/sshd_config. Вы захотите посмотреть этот файл и убедиться, что все настроено правильно, потому что (a ), если нет, то служба не запустится, и о ней будет сообщено systemctl status и (b )если служба запускается с зеленым ОК, вы все равно не сможете войти в систему по ssh.

здесь значение по умолчанию /etc/ssh/sshd_config, которое на самом деле взято из Centos 7.6, но должно быть точно таким же, как в RHEL 7.6; если ваша служба SSH не запускается, вы можете попробовать создать резервную копию существующей sshd _конфигурации в /etc/ssh/sshd _конфигурации _старой и использовать это один;если служба sshd по-прежнему не запускается, то это не проблема с файлом sshd _config , так как это значение по умолчанию, которое поставляется с установкой RHEL/Centos 7 и работает для всех при новой установке.

#   $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

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

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

# 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 override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

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

#PubkeyAuthentication yes

# The default is to check both.ssh/authorized_keys and.ssh/authorized_keys2
# but this is overridden so installations will only check.ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# 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
PasswordAuthentication yes

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

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

# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no

# 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 and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

# override default of no subsystems
Subsystem   sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server
0
28.01.2020, 00:04

RH5 использовал программу инициализации SVR4 для управления демонами. RH7 удалил SVR4 init и заменил его на systemd .

Команда serviceустарела, и вы перестали бы ее использовать. serviceтеперь представляет собой простую оболочку вокруг "новой" systemctlкоманды (для ретро-совместимости -со спецификациями LSB ).

Насколько я знаю, systemctlне поддерживает какие-либо выходные теги .

Если вам нужно программно проверить статус службы, systemctlпредлагает множество «команд» для получения статуса службы. Например. systemctl is-active sshd.service, systemctl is-enabled sshd.service, systemctl is-failed sshd.service, systemctl is-system-running sshd.service.

0
28.01.2020, 00:04

Теги

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