Skip to content
Snippets Groups Projects
Commit d47969bb authored by Jupiter Hu's avatar Jupiter Hu
Browse files

remove openssh config template, replace by editing

parent 8a0e913e
No related branches found
No related tags found
No related merge requests found
......@@ -38,21 +38,35 @@
sudo: true
when: ansible_os_family == "RedHat"
- name: copy config script
template: dest={{ ssh_dir }}/etc/sshd_config src=sshd_config_centos.j2 mode=644
notify: restart openssh
sudo: true
when: ansible_os_family == "RedHat"
- name: copy init script
template: dest=/etc/init.d/{{ sshd_name }} src=ssh.initd.debian.j2 mode=755
sudo: true
sudo: true
when: ansible_os_family == "Debian"
- name: copy config script
template: dest={{ ssh_dir }}/etc/sshd_config src=sshd_config_debian.j2 mode=644
notify: restart openssh
sudo: true
when: ansible_os_family == "Debian"
- name: check config file
stat: path=/etc/ssh/sshd_config
register: ssh_config
ignore_errors: true
- name: create config file link
file: src={{ ssh_dir }}/etc dest=/etc/ssh state=link force=yes
sudo: true
when: ssh_config.stat.exists == false
- name: edit config file replace"
lineinfile: dest=/etc/ssh/sshd_config line="{{ item.line }}" regexp="{{ item.regexp }}" backrefs=yes
with_items:
- {line: "HostKey /etc/ssh/ssh_host_rsa_key", regexp: "^#HostKey /etc/ssh/ssh_host_rsa_key"}
- {line: "HostKey /etc/ssh/ssh_host_dsa_key", regexp: "^#HostKey /etc/ssh/ssh_host_dsa_key"}
- {line: "#GSSAPIAuthentication yes", regexp: "^GSSAPIAuthentication yes"}
- {line: "#GSSAPICleanupCredentials yes", regexp: "^GSSAPICleanupCredentials yes"}
sudo: true
- name: edit config file attache lines"
lineinfile: dest=/etc/ssh/sshd_config line="{{ item }}"
with_items:
- "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1"
- "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour"
notify: restart openssh
sudo: true
......@@ -31,22 +31,19 @@
# pull in sysconfig settings
[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
[ -f /etc/profile.d/modules.sh ] && . /etc/profile.d/modules.sh
module load openssh
RETVAL=0
prog="ssh"
lockfile=/var/lock/subsys/${prog}
# Some functions to make the below more readable
SSH_HOME={{ ssh_dir }}
KEYGEN=${SSH_HOME}/bin/ssh-keygen
SSHD=${SSH_HOME}/sbin/sshd
SSHD_CONFIG=${SSH_HOME}/etc/sshd_config
RSA1_KEY=${SSH_HOME}/etc/ssh_host_key
RSA_KEY=${SSH_HOME}/etc/ssh_host_rsa_key
DSA_KEY=${SSH_HOME}/etc/ssh_host_dsa_key
SSHD_CONFIG=/etc/ssh/sshd_config
RSA1_KEY=/etc/ssh/ssh_host_key
RSA_KEY=/etc/ssh/ssh_host_rsa_key
DSA_KEY=/etc/ssh/ssh_host_dsa_key
PID_FILE=/var/run/sshd.pid
##PID_FILE=${SSH_HOME}/var/run/sshd.pid
##SSHD_LOG="${SSH_HOME}/var/log/sshd.log"
OPTIONS="-f ${SSHD_CONFIG}"
runlevel=$(set -- $(runlevel); eval "echo \$$#" )
......@@ -146,9 +143,6 @@ start()
RETVAL=$?
echo "return $RETVAL"
[ $RETVAL -eq 0 ] && touch $lockfile
echo "Start OK"
sleep 2
cp -f /var/run/sshd.pid ${PID_FILE}; cp -f /var/run/sshd.pid.ori /var/run/sshd.pid
return $RETVAL
}
......
......@@ -30,7 +30,7 @@ SSHD_LOG="${SSHD_LOG_DIR}/sshd.log"
PID_DIR="{{ ssh_pid_dir }}"
###PID_DIR="${SSH_HOME}/var/run"
PID_FILE=${PID_DIR}/sshd.pid
SSHD_CONFIG=${SSH_HOME}/etc/sshd_config
SSHD_CONFIG=/etc/ssh/sshd_config
SSHD="${SSH_HOME}/sbin/sshd"
SSHD_OPTS="-f ${SSHD_CONFIG}"
......
# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm 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:/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 change a
# default value.
Port {{ ssh_port }}
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
# 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 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody
# 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
PasswordAuthentication no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange 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'.
#UsePAM no
UsePAM yes
# 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
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#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
# no default banner path
#Banner none
# 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
# ForceCommand cvs server
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port {{ ssh_port }}
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
Banner /etc/ssh/sshd_banner
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# 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'.
UsePAM yes
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment