Hi @Mark_De_May and welcome to the MongoDB Community forums.
To connect to a secondary member you would use mongo
(installed 5.0.x and earlier) or mongosh
(installed with 6.0.x and later). Something like the following:
mongosh mongodb://<URI or IP of secondary>:<port> -u <user> -p <other parameters as needed>
Note that we are not passing in the password so it will prompt you for that. This is the safe way as your password is not exposed on the command line or in the command history.
Once you connect, and authenticate to the secondary node you can do your compaction.