mirror of https://github.com/apache/jclouds.git
Fix for ssh reload for CentOS 7
This commit is contained in:
parent
1e4d0beae2
commit
cf5a66ab14
|
@ -224,7 +224,7 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
setupPublicCurl || return 1
|
||||
|
|
|
@ -224,7 +224,7 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
setupPublicCurl || return 1
|
||||
|
|
|
@ -105,7 +105,7 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SshdConfig implements Statement {
|
|||
Statement prependSshdConfig = exec(String.format(
|
||||
"exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
|
||||
linesToPrepend));
|
||||
Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload");
|
||||
Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload");
|
||||
return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SshStatementsTest {
|
|||
.append("PasswordAuthentication no").append("\n")//
|
||||
.append("PermitRootLogin no").append("\n")//
|
||||
.append("\" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3").append("\n")//
|
||||
.append("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload").append("\n").toString());
|
||||
.append("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload").append("\n").toString());
|
||||
}
|
||||
|
||||
public void testSshdConfigUNIX() {
|
||||
|
@ -40,7 +40,7 @@ public class SshStatementsTest {
|
|||
new StringBuilder().append("exec 3<> /etc/ssh/sshd_config && awk -v TEXT=\"")//
|
||||
.append("AddressFamily inet6").append("\n")//
|
||||
.append("\" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3").append("\n")//
|
||||
.append("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload").append("\n").toString());
|
||||
.append("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload").append("\n").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ chown -R foo /over/ridden/foo
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(0)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
|
|
|
@ -19,6 +19,6 @@ chown -R foo /over/ridden/foo
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(0)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
|
|
|
@ -19,6 +19,6 @@ chown -R defaultAdminUsername /home/users/defaultAdminUsername
|
|||
exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no
|
||||
PermitRootLogin no
|
||||
" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3
|
||||
hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload
|
||||
hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload
|
||||
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(1)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
|
||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||
|
|
Loading…
Reference in New Issue