"Not Absolute Home" Error Over Network: SSH

Given code

Net::SSH.start('server name', 'user') 

This returns "not an absolute home." The "user" actually has a home directory. One of the suggested methods was to change ~ / .ssh / config with full paths to IdentityFile. This did not solve the problem.

The crazy part of this is that the code works fine if called via irb or console. The moment we try to call it from a class method (with the same code), it returns a "not absolute home" error.

The "user" can also ssh to the server via the command line without any problems. Ubuntu is running on the server.

UPDATE

Thanks to @Phrogz, the fix for this was to install ENV ['HOME'] in '/ home / deploy'. However, I did not understand why $ HOME gets the value ".". on server. So, I will leave this question without an β€œanswer” until I, or someone else, knows about it. To manually install HOME, it looks more like a β€œhack” than the right solution, but it works.

+8
ruby ruby-on-rails-3 net-ssh
source share
3 answers

We ran into the same problem and found the root cause. We use our script as a service, and if you check the man page for the service, it transfers most of the env variables before running the script, including HOME. I don't know if your script matches, but HOME is not installed.

net-ssh wants to find the ssh configuration from the users home folder, so it used the value "." to force ENV ['HOME']. if it has not been installed. But when File.expand_path tries to expand "~ / .ssh", an ArgumentError argument is created.

This was fixed two months ago ( https://github.com/net-ssh/net-ssh/pull/98 ), so updating your net-ssh chip should fix this problem.

+2
source share

This definitely works by installing HOME env var if it is not installed.

+1
source share

Linux installs this information based on the /etc/passwd .

Verify that exists in /etc/passwd for the deployer user. It should be at the bottom of the list.

Elements are separated by colons. The value for ENV['HOME'] must be from the second to the last entry on this line.

It is empty, i.e. has two colons together?

I suspect that your HOME variable is not in /etc/passwd and is set to one of the default files, i.e. something like .bashrc . Then .bashrc closes if your application is launched through an init.d script that does not create your dotfiles. (Many .bashrc files stop loading the remaining commands if they are executed through a non-interactive shell).

Hope this helps, and please send back your results.

0
source share

All Articles