The code in question
Net::SSH.start('server name', 'user')
This returns "non-absolute home". The 'user' in fact does have a home directory. One suggested approach was to modify ~/.ssh/config with full paths to the IdentityFile. This did not solve the issue.
The crazy part of this is that the code works fine if called through irb or console. The moment we try calling it from within a class method (with the same code) it returns the "non-absolute home" error.
The 'user' can also ssh into the server via command line without issue. The server is running Ubuntu.
UPDATE
Thanks to @Phrogz - The fix for this was setting ENV['HOME'] to '/home/deploy'. However, I have not figured out why $HOME is getting set to "." on the server. So, I will leave this question up without an "Answer" until I, or someone else, figures that out. Having to manually set HOME feels more like a "hack" than a proper solution, but it does work.
We just ran into the same problem, and found the root cause. We're running our script as a service, and if you check the manpage for service, it strips most env variables before running the script, including HOME. I don't know if your scenario is the same, but HOME is not set.
net-ssh wants to look up ssh config from the users home folder, so it used to force ENV['HOME'] to "." if it was not set. But when File.expand_path tries to expand "~/.ssh" the ArgumentError is raised.
This was fixed two months ago ( https://github.com/net-ssh/net-ssh/pull/98 ), so updating your net-ssh gem should resolve this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With