I suspect the issue is that the environment differs between a regular login and a SSH logon. You can confirm this by logging into the Mac instance via SSH and running
command -v mono
In a local login you will see the path to the mono executable, but in the SSH session this may not return anything, which is why the deployment is failing.
This is a copy of the checks that are performed by the Octopus server.
SESSION_TYPE=local
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_TYPE=SSH
else
case $(ps -o comm= -p $PPID) in
sshd|*/sshd) SESSION_TYPE=SSH;;
esac
fi
echo $SESSION_TYPE
declare -a arr=("df" "ls" "grep" "openssl" "mkdir" "tar" "mono")
deps=0
for cmd in "${arr[@]}";
do
echo Testing for $cmd
command -v $cmd
if [[ $? != 0 ]]; then
echo >&2 "Required command '$cmd' is not available.";
deps=1;
fi
done;
if [[ $deps != 0 ]]; then exit 127; fi
Can you try saving this to a file called test.sh and running it against the Mac target with a command like this (you will need to replace the key name so it matches your local private key):
This will simulate the check that is performed by the Octopus server. If you can paste in the result of this script that will help us narrow down the issue.
IIT-AS-002:~ octopus$ bash test.sh
SSH
Testing for df
/bin/df
Testing for ls
/bin/ls
Testing for grep
/usr/bin/grep
Testing for openssl
/usr/bin/openssl
Testing for mkdir
/bin/mkdir
Testing for tar
/usr/bin/tar
Testing for mono
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
I don’t know if that changes anything, but the Octopus Server is connecting to IIT-AS-002 (the Apple server) with username/password, not with public/private keys.
I’m ran the tests throught an SSH connection started from Bitvise (my SSH client on Windows).
There is an option to use raw scripting for SSH targets that might help us here. You can enable raw scripting by creating a project using the instructions at https://octopus.com/blog/trying-raw-octopus#setting-it-up. This removes the need for mono on the target system.
If you don’t need the full capabilities provided by Calamari (which is what has the dependency on mono), raw scripting may be a valid workaround for you.
If you do need the functionality provided by Calamari, then we can test the environment that Octopus logs into by creating a script step and placing the example script above into it (see the attached screenshot for an example).
Many thanks for your help. It guided me in the right direction.
You were right when you said that the environment differs between a regular login and a SSH logon.
The solution was to create the .bashrc file in the home (~) directory of the Octopus Deploy user (named simply “octopus” in my case).
For me, on the Apple machine, the home directory was /Users/octopus.
This way, the $PATH will always contain the location of the mono binaries.
I first tried doing this with the ~\.bash_profile file, but that’s for the login shell. Octopus Deploy starts an interactive, non-login shell, and thus use the shell config ~\.bashrc for Bash.