*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
- Login With Public Key ${USERNAME} ${SSH_KEYFILE}
+ Run Keyword IF '${SSH_KEYFILE}' != 'None' Login With Public Key ${USERNAME} ${SSH_KEYFILE} ELSE IF '${PASSWORD}' != 'None' Login ${USERNAME} ${PASSWORD} ELSE FAIL
Get Cluster Address
${result}= Run Process kubectl config view --minify
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
- Login With Public Key ${USERNAME} ${SSH_KEYFILE}
+ Run Keyword IF '${SSH_KEYFILE}' != 'None' Login With Public Key ${USERNAME} ${SSH_KEYFILE} ELSE IF '${PASSWORD}' != 'None' Login ${USERNAME} ${PASSWORD} ELSE FAIL
Install Lynis
[Documentation] Install Lynis
Library OperatingSystem
Library BuiltIn
Suite Setup Open Connection And Log In
-Suite Teardown Close All Connections
+Suite Teardown Run Keywords
+... Cleanup ssh
+... Close All Connections
*** Test Cases ***
Run Vuls test
${os} = SSHLibrary.Execute Command source /etc/os-release && echo $ID
+ Run Keyword IF '${SSH_KEYFILE}' == 'None' Create ssh_keyfile
+
${rc} = Run And Return Rc vuls scan -config ${CURDIR}/config.toml -ssh-config
Should Be Equal As Integers ${rc} 0
Append To File ${LOG_PATH}/vuls.log ${output}${\n}
Set Global Variable ${LOG} ${output}
+Create ssh_keyfile
+ ${rc} = Run And Return Rc ssh-keygen -t rsa -b 4096 -f /root/.ssh/id_rsa -N ""
+ Should Be Equal As Integers ${rc} 0
+
+ ${rc} = Run and Return Rc sshpass -p '${PASSWORD}' ssh-copy-id -i /root/.ssh/id_rsa.pub '${USERNAME}'@'${HOST}'
+ Should Be Equal As Integers ${rc} 0
+
+Cleanup ssh
+ ${rc} ${idssh} = Run And Return Rc And Output cat /root/.ssh/id_rsa.pub
+ Should Be Equal As Integers ${rc} 0
+ ${rc} = Run And Return Rc ssh '${USERNAME}'@'${HOST}' "sed -i 's#${idssh}##' ~/.ssh/authorized_keys"
+ Should Be Equal As Integers ${rc} 0
+
Open Connection And Log In
Open Connection ${HOST}
- Login With Public Key ${USERNAME} ${SSH_KEYFILE}
+ Run Keyword IF '${SSH_KEYFILE}' != 'None' Login With Public Key ${USERNAME} ${SSH_KEYFILE} ELSE IF '${PASSWORD}' != 'None' Login ${USERNAME} ${PASSWORD} ELSE FAIL
### Input variables cluster's master host
host: 172.28.17.206 # cluster's master host address
username: cloudadmin # login name to connect to cluster
-ssh_keyfile: /root/.ssh/id_rsa # Identity file for authentication
+password: cloudpassword # login password to connect to cluster
+ssh_keyfile: ssh_keyfile # Identity file for authentication
### bluval.py adds/modifies following, before passing to robot.
### while debugging from CLI user has to modify these