Ssh using etc passwd instead of $HOME

From FVue
Jump to: navigation, search

Problem

I want to change the $HOME directory to use a different config for ssh testing purposes. Ssh, however, doesn't use the modified $HOME:

$ ssh -v foo
OpenSSH_4.6p1 Debian-5ubuntu0.1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /home/myname/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
ssh: foo: Name or service not known
$ export HOME=/tmp; ssh -v foo
OpenSSH_4.6p1 Debian-5ubuntu0.1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /home/myname/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
ssh: foo: Name or service not known

Solution

It's considered good practice to obtain $HOME from /etc/passwd. I guess it makes SSH more secure as well, because changing /etc/passwd requires root privileges while changing the $HOME environment variable is much easier for a bad willing person.

Re: howto change home path in /etc/passwd
Forum message using the phrase "Unix tradition"

Workaround

For an alternate config, use the -F parameter to ssh:

-F configfile
Specifies an alternative per-user configuration file. If a configuration file is given on the command line, the system-wide configuration file (/etc/ssh/ssh_config) will be ignored. The default for the per-user configuration file is ~/.ssh/config.

Comments

blog comments powered by Disqus