Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have installed CygWin v1.7.28.

The problem quickly explained: Basically, when starting a CygWin shell via remote login, the $HOME is not where it should, with all derivated (bad) consequences of it. Local consoles performs OK.

And now for the details:

If on the GUI (Windows XP) I do:

c:\CygWin\bin\bash.exe --login -i

or (same way, practically):

c:\CygWin\Cygwin.bat

I start at the correct $HOME with all my config files:

LuisRivas@portatilacer ~
$ pwd
/home/LuisRivas

LuisRivas@portatilacer ~
$ ls .* -la
-rw-------  1 LuisRivas Ninguno  108 mar  3 14:34 .bash_history
-rwxr-xr-x  1 LuisRivas Ninguno 1494 mar  3 03:00 .bash_profile
-rwxr-xr-x  1 LuisRivas Ninguno 6127 mar  3 14:28 .bashrc
-rwxr-xr-x  1 LuisRivas Ninguno 1919 mar  3 03:00 .inputrc
-rwxr-xr-x  1 LuisRivas Ninguno 1236 mar  3 03:00 .profile

$ echo $HOME
/home/LuisRivas

But if I log via SSH (Bitvise SSH Server v6 installed on Windows XP SP3) and I repeat the process (same user):

c:\CygWin\bin\bash.exe --login -i

Now the Bash Shell does not start where it should:

LuisRivas@portatilacer ~
$ echo $HOME
/cygdrive/c/Documents and Settings/LuisRivas

LuisRivas@portatilacer ~
$ pwd
/cygdrive/c/Documents and Settings/LuisRivas

LuisRivas@portatilacer ~
$ ls .* -la
-rw-------+ 1 LuisRivas       Ninguno 197 mar  3 14:36 .bash_history

.:
total 1211
drwxrwx---+ 1 Administradores SYSTEM       0 mar  3 14:30 .
drwxrwxr-x+ 1 Administradores SYSTEM       0 mar  1 04:06 ..
-rw-------+ 1 LuisRivas       Ninguno    197 mar  3 14:36 .bash_history
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:12 Configuración local
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 15:41 Cookies
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:17 Datos de programa
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 13:56 Entorno de red
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 13:56 Escritorio
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:12 Favoritos
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:02 IETldCache
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 13:56 Impresoras
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 13:56 Menú Inicio
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:12 Mis documentos
-rwx------+ 1 LuisRivas       Ninguno 786432 mar  3 14:17 NTUSER.DAT
-rwx------+ 1 LuisRivas       Ninguno   1024 mar  3 14:34 NTUSER.DAT.LOG
-rwxrwx---+ 1 Administradores SYSTEM     192 mar  3 14:03 ntuser.ini
drwx------+ 1 LuisRivas       Ninguno      0 dic 25 15:33 Plantillas
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:12 Reciente
drwx------+ 1 LuisRivas       Ninguno      0 mar  3 14:12 SendTo

That is: CygWin started the shell at my Windows home directory, so I don't have my personalizations (.bashrc, .bash_profile ... etc), like aliases.

Maybe this strange behavior is just caused by some kind of missing environment variable (that exists on GUI, but not on remote console), but I have not been able to locate it.
How could I do to make my remote console to start the Bash Shell included in CygWin where it should?

  • EDIT: here some extra data upon request:

At local Bash Shell:

LuisRivas@portatilacer ~
$ id
uid=1004(LuisRivas) gid=513(Ninguno) grupos=513(Ninguno),0(root),544(Administradores),545(Usuarios)

At remote Bash Shell (nothing differs):

LuisRivas@portatilacer ~
$ id
uid=1004(LuisRivas) gid=513(Ninguno) grupos=513(Ninguno),0(root),544(Administradores),545(Usuarios)

And this is the content of /etc/passwd (only shown the user "LuisRivas" line):

LuisRivas@portatilacer ~
$ cat /etc/passwd
[Lines not needed (I think)]
LuisRivas:unused:1004:513:U-PORTATILACER\LuisRivas,S-1-5-21-789336058-1957994488-1417001333-1004:/home/LuisRivas:/bin/bash
[Lines not needed (I think)]
  • EDIT 2: In a first writing I was wrong: the file .bashrc at the starting path (wherever this path is) is read OK by CygWin when starting its shell. That info is deleted now.

  • EDIT 3: My tests have only been made on SSH remote logins, not Telnet. So came the problem: precisely from some behavior of Bitvise SSH Server (read response below).

share|improve this question
1  
There several possible issues at hand. What does your /etc/passwd say? Also try to issue id in each case and let us know the result. Last, if you send remote commands via SSH, then they might be executed as cyg_server and not as the SSH user. –  user1147688 Mar 4 at 0:03
    
I have edited the question to add those details. I pasted from /etc/passwd only the line concerning to the logged user. Thanks, @user1147688. –  Sopalajo de Arrierez Mar 4 at 1:47
    
Hmm, strange. Please also try editrights.exe -l -u LuisRivas and mkpasswd --local |grep LuisRivas. –  user1147688 Mar 4 at 2:03
1  
You should look at the solution to the very similar issue here. –  user1147688 Mar 4 at 10:40
    
That's correct, friend. That was the solution.. I have posted it as an answer to be easy to read. –  Sopalajo de Arrierez Mar 4 at 14:44

2 Answers 2

For me, the problem was not due to a Windows environmental variable %HOME% that I was able to delete. No %HOME% variable was listed in the Environmental Variables dialog box.

Instead, I was able to solve the problem in Bitvise by unchecking "Permit environmental variables" in the advanced settings. I also deleted "%HOME%" in the field Initial terminal shell directory, but that wasn't enough by itself.

share|improve this answer

The problem in just a few words: Bitvise SSH Server (Windows) adds an (supposedly illogical; seems not to be needed) environment variable %HOME% that equals to %HOMEPATH%.

The solution: the possibility of managing the environment variables that Bitvise SSH Server adds to every SSH client (Putty, classic GNU command-line SSH... etc). As long as I have researched about, the program doesn't have this functionality. I will keep searching.

Workarounds:

  1. Call the Bash Shell via a .cmd file that first deletes the %HOME% environment variable. Something like:

    @ set HOME=
    @ c:\CygWin\bin\bash.exe --login -i

  2. Starting the Bash Shell by changing the $HOME value, and restarting it:

    c:\CygWin\bin\bash.exe --login -i -c "export HOME=/home/%USERNAME%;cd /home/%USERNAME%; exec /bin/bash"

  3. Just copying all configuration files from c:\CygWin\home\%USERNAME% to c:\User\%USERNAME%. Seems to work OK (does anybody knows about some issue with this method?).

Thanks to @user1147688 (above) for ideas and link to solution from a similar question.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.