Can't login to server with SSH because of a script in /etc/profile.d exiting with exit status 1












2














so I have this problem, I can't login to my server with SSH.
See:



ssh -v myuser@myserver
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Sun Jul 5 20:10:54 2015 from x.x.x.x
-bash: KSH_VERSION: unbound variable
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to x.x.x.x closed.
Transferred: sent 2264, received 2800 bytes, in 0.2 seconds
Bytes per second: sent 13241.8, received 16376.8
debug1: Exit status 1


The problem is the "-bash: KSH_VERSION: unbound variable", this kills the connection I think.
I know why is it happening…I was working on a script placed in /etc/profile.d, and this script has "set -euo pipefail" (ouch) in it...
The "o" option is "nounset" and that exaplains the "unbound variable"...
When the script sets the options, it make the vim.sh there failing on the unbound variable.



Now, how get around this? I can't send just a command there over ssh, to remove the file for example, I can't login as another user, I can't use another shell, the "--noprofile" and "--norc" options for bash doesn't work…no trick I tried worked…



Any ideas, pretty please?










share|improve this question




















  • 1




    Does this work? ssh myuser@myserver hostname
    – Cyrus
    Jul 5 '15 at 20:29










  • nope, it doesn't :( same problem...
    – stibi
    Jul 5 '15 at 20:30










  • The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
    – Andrew Henle
    Jul 5 '15 at 22:46










  • If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
    – saiarcot895
    Jul 6 '15 at 23:09


















2














so I have this problem, I can't login to my server with SSH.
See:



ssh -v myuser@myserver
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Sun Jul 5 20:10:54 2015 from x.x.x.x
-bash: KSH_VERSION: unbound variable
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to x.x.x.x closed.
Transferred: sent 2264, received 2800 bytes, in 0.2 seconds
Bytes per second: sent 13241.8, received 16376.8
debug1: Exit status 1


The problem is the "-bash: KSH_VERSION: unbound variable", this kills the connection I think.
I know why is it happening…I was working on a script placed in /etc/profile.d, and this script has "set -euo pipefail" (ouch) in it...
The "o" option is "nounset" and that exaplains the "unbound variable"...
When the script sets the options, it make the vim.sh there failing on the unbound variable.



Now, how get around this? I can't send just a command there over ssh, to remove the file for example, I can't login as another user, I can't use another shell, the "--noprofile" and "--norc" options for bash doesn't work…no trick I tried worked…



Any ideas, pretty please?










share|improve this question




















  • 1




    Does this work? ssh myuser@myserver hostname
    – Cyrus
    Jul 5 '15 at 20:29










  • nope, it doesn't :( same problem...
    – stibi
    Jul 5 '15 at 20:30










  • The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
    – Andrew Henle
    Jul 5 '15 at 22:46










  • If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
    – saiarcot895
    Jul 6 '15 at 23:09
















2












2








2


2





so I have this problem, I can't login to my server with SSH.
See:



ssh -v myuser@myserver
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Sun Jul 5 20:10:54 2015 from x.x.x.x
-bash: KSH_VERSION: unbound variable
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to x.x.x.x closed.
Transferred: sent 2264, received 2800 bytes, in 0.2 seconds
Bytes per second: sent 13241.8, received 16376.8
debug1: Exit status 1


The problem is the "-bash: KSH_VERSION: unbound variable", this kills the connection I think.
I know why is it happening…I was working on a script placed in /etc/profile.d, and this script has "set -euo pipefail" (ouch) in it...
The "o" option is "nounset" and that exaplains the "unbound variable"...
When the script sets the options, it make the vim.sh there failing on the unbound variable.



Now, how get around this? I can't send just a command there over ssh, to remove the file for example, I can't login as another user, I can't use another shell, the "--noprofile" and "--norc" options for bash doesn't work…no trick I tried worked…



Any ideas, pretty please?










share|improve this question















so I have this problem, I can't login to my server with SSH.
See:



ssh -v myuser@myserver
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Sun Jul 5 20:10:54 2015 from x.x.x.x
-bash: KSH_VERSION: unbound variable
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to x.x.x.x closed.
Transferred: sent 2264, received 2800 bytes, in 0.2 seconds
Bytes per second: sent 13241.8, received 16376.8
debug1: Exit status 1


The problem is the "-bash: KSH_VERSION: unbound variable", this kills the connection I think.
I know why is it happening…I was working on a script placed in /etc/profile.d, and this script has "set -euo pipefail" (ouch) in it...
The "o" option is "nounset" and that exaplains the "unbound variable"...
When the script sets the options, it make the vim.sh there failing on the unbound variable.



Now, how get around this? I can't send just a command there over ssh, to remove the file for example, I can't login as another user, I can't use another shell, the "--noprofile" and "--norc" options for bash doesn't work…no trick I tried worked…



Any ideas, pretty please?







bash shell ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 5 '15 at 20:29







stibi

















asked Jul 5 '15 at 20:23









stibistibi

11115




11115








  • 1




    Does this work? ssh myuser@myserver hostname
    – Cyrus
    Jul 5 '15 at 20:29










  • nope, it doesn't :( same problem...
    – stibi
    Jul 5 '15 at 20:30










  • The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
    – Andrew Henle
    Jul 5 '15 at 22:46










  • If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
    – saiarcot895
    Jul 6 '15 at 23:09
















  • 1




    Does this work? ssh myuser@myserver hostname
    – Cyrus
    Jul 5 '15 at 20:29










  • nope, it doesn't :( same problem...
    – stibi
    Jul 5 '15 at 20:30










  • The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
    – Andrew Henle
    Jul 5 '15 at 22:46










  • If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
    – saiarcot895
    Jul 6 '15 at 23:09










1




1




Does this work? ssh myuser@myserver hostname
– Cyrus
Jul 5 '15 at 20:29




Does this work? ssh myuser@myserver hostname
– Cyrus
Jul 5 '15 at 20:29












nope, it doesn't :( same problem...
– stibi
Jul 5 '15 at 20:30




nope, it doesn't :( same problem...
– stibi
Jul 5 '15 at 20:30












The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
– Andrew Henle
Jul 5 '15 at 22:46




The man page for ssh (linux.die.net/man/1/ssh) documents a -N option to not execute a remote command. I don't know if there's a way to pass that to scp so you can update the file, but you might be able to forward ports to the remote machine and get access through them if for example, normal FTP is allowed from localhost.
– Andrew Henle
Jul 5 '15 at 22:46












If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
– saiarcot895
Jul 6 '15 at 23:09






If this is running Debian (or a derivative), you can try using /bin/dash as the shell instead. Not sure if it will work... Edit: Never mind, it reads /etc/profile.
– saiarcot895
Jul 6 '15 at 23:09












7 Answers
7






active

oldest

votes


















2














You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced:



$ ssh -v localhost
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
........
Authenticated to localhost ([::1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Tue Jul 7 19:46:42 2015 from localhost
^C-bash-4.2$




Edit to clarify a few things:



When sshd opens a session on the server, it does so by reading the user shell (that is /bin/bash in this case).



It does not matter whatever option is given on bash or ssh command to run (including sftp). That ssh command (including sftp) or bash option is passed to a bash instance after a session is opened. You have no control on what that instance does. For example:



client$ ssh localhost bash --noprofile --norc


strace output on the server:



[pid 60047] execve("/bin/bash", ["bash", "-c", "bash --noprofile --norc"], [/* 16 vars */]) = 0
[pid 60047] execve("/usr/bin/bash", ["bash", "--noprofile", "--norc"], [/* 28 vars */]) = 0


As you can see the ssh command ("bash --noprofile --norc") is passed on the first execve as an argument to "bash" with the "-c" option.



That first bash instance that you have no control on with read ~/.bashrc which in turn will read /etc/bashrc which will load the scripts under /etc/profile.d/ (at least on a Red Hat system - I don't know about others).



[pid 60047] open("/home/user/.bashrc", O_RDONLY) = 3
[pid 60047] open("/etc/bashrc", O_RDONLY) = 3


The only way I can think of is the above, been quick enough to abort the login process before the scripts are loaded (but not to quick as to abort the session). - You might want to increase the load on the system (if it's possible) to give you more time during the login process.



ps. if you find the answer useful please mark it






share|improve this answer























  • nice, this is cool
    – stibi
    Jul 7 '15 at 16:52










  • Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
    – Mark Thomson
    Dec 30 '18 at 23:12



















1














I had the same problem and finally found a solution.



As @nkms mentioned:




You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced




To raise you chances i've used the following loop:



$ (trap '' INT; while true; do ssh myuser@myserver; done)


The script starts subshell '(' and deactivates the ctr-c command for that subshell (with the trap command). Then it loops over the ssh command.
If you continuously press ctrl-c or hold down ctrl-c, you raise you chances to hit the right moment.



... works like a charm!






share|improve this answer

















  • 1




    It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
    – Mark Thomson
    Dec 30 '18 at 23:06












  • @MarkThomson: THX!
    – st0ne
    Jan 4 at 9:38



















0














Does sftp also fail ? If doesn't, you could make use of that to place a good /etc/profile.d file there.






share|improve this answer





















  • good idea, but doesn't work either, it fail with "Connection closed"
    – stibi
    Jul 5 '15 at 20:37












  • Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
    – steve
    Jul 5 '15 at 20:44










  • For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
    – stibi
    Jul 5 '15 at 20:46






  • 3




    What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
    – Satō Katsura
    Jul 5 '15 at 20:47










  • scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
    – stibi
    Jul 5 '15 at 22:15



















0














I have two problems with your question.



ps -A|grep bash|wc -l


and the same command in



ssh localhost 'csh -l'


give the same number.



So it does not seem that a bash is run before 'csh -l'.



On the other hand csh does not use /etc/profile.



strace -eopen csh -l



does not show any entry of /etc/profile*.



So I am not sure the problem you have is in /etc/profile*.



Am I missing something?






share|improve this answer



















  • 1




    the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
    – stibi
    Jul 7 '15 at 16:45










  • So just deleting a script in /etc/profile.d/ solved the problem?
    – Jodka Lemon
    Jul 7 '15 at 16:47










  • Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
    – stibi
    Jul 7 '15 at 16:51



















0














This is unlikely to work, but you could try sending a value for KSH_VERSION when you make the ssh connection:



KSH_VERSION=x ssh -v -o 'SendEnv=KSH_VERSION' myuser@myserver


The idea is to set the environment variable to something, so that bash won't complain that it's unset. I say it's unlikely to work because the default SSH server configuration wouldn't permit you to set this particular variable. This would only work if someone had reason to make that setting more lenient on this particular server.






share|improve this answer





















  • you are correct in all points :) doesn't work, because of the reasons you exaplained
    – stibi
    Jul 7 '15 at 16:44



















0














I ended up with the same problem, but was installing something else and fixed it once I removed the below:



/etc/sysctl.conf
fs.file-max=100000


Then



/etc/security/limits.conf:
* soft nofile 1000000
* hard nofile 1000000


Lastly



/etc/pam.d/common-session:
session required pam_limits.so





share|improve this answer








New contributor




BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    -1














    Try ssh -t username@hostname /bin/sh --noprofile.






    share|improve this answer























    • Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
      – stibi
      Jul 5 '15 at 20:52






    • 1




      And a different shell?
      – Jodka Lemon
      Jul 6 '15 at 16:03










    • ksh, csh…both invoking /etc/profile, no go
      – stibi
      Jul 7 '15 at 6:49










    • What does csh -f?
      – Jodka Lemon
      Jul 7 '15 at 9:49











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f214042%2fcant-login-to-server-with-ssh-because-of-a-script-in-etc-profile-d-exiting-wit%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    7 Answers
    7






    active

    oldest

    votes








    7 Answers
    7






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced:



    $ ssh -v localhost
    OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
    ........
    Authenticated to localhost ([::1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    Last login: Tue Jul 7 19:46:42 2015 from localhost
    ^C-bash-4.2$




    Edit to clarify a few things:



    When sshd opens a session on the server, it does so by reading the user shell (that is /bin/bash in this case).



    It does not matter whatever option is given on bash or ssh command to run (including sftp). That ssh command (including sftp) or bash option is passed to a bash instance after a session is opened. You have no control on what that instance does. For example:



    client$ ssh localhost bash --noprofile --norc


    strace output on the server:



    [pid 60047] execve("/bin/bash", ["bash", "-c", "bash --noprofile --norc"], [/* 16 vars */]) = 0
    [pid 60047] execve("/usr/bin/bash", ["bash", "--noprofile", "--norc"], [/* 28 vars */]) = 0


    As you can see the ssh command ("bash --noprofile --norc") is passed on the first execve as an argument to "bash" with the "-c" option.



    That first bash instance that you have no control on with read ~/.bashrc which in turn will read /etc/bashrc which will load the scripts under /etc/profile.d/ (at least on a Red Hat system - I don't know about others).



    [pid 60047] open("/home/user/.bashrc", O_RDONLY) = 3
    [pid 60047] open("/etc/bashrc", O_RDONLY) = 3


    The only way I can think of is the above, been quick enough to abort the login process before the scripts are loaded (but not to quick as to abort the session). - You might want to increase the load on the system (if it's possible) to give you more time during the login process.



    ps. if you find the answer useful please mark it






    share|improve this answer























    • nice, this is cool
      – stibi
      Jul 7 '15 at 16:52










    • Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
      – Mark Thomson
      Dec 30 '18 at 23:12
















    2














    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced:



    $ ssh -v localhost
    OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
    ........
    Authenticated to localhost ([::1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    Last login: Tue Jul 7 19:46:42 2015 from localhost
    ^C-bash-4.2$




    Edit to clarify a few things:



    When sshd opens a session on the server, it does so by reading the user shell (that is /bin/bash in this case).



    It does not matter whatever option is given on bash or ssh command to run (including sftp). That ssh command (including sftp) or bash option is passed to a bash instance after a session is opened. You have no control on what that instance does. For example:



    client$ ssh localhost bash --noprofile --norc


    strace output on the server:



    [pid 60047] execve("/bin/bash", ["bash", "-c", "bash --noprofile --norc"], [/* 16 vars */]) = 0
    [pid 60047] execve("/usr/bin/bash", ["bash", "--noprofile", "--norc"], [/* 28 vars */]) = 0


    As you can see the ssh command ("bash --noprofile --norc") is passed on the first execve as an argument to "bash" with the "-c" option.



    That first bash instance that you have no control on with read ~/.bashrc which in turn will read /etc/bashrc which will load the scripts under /etc/profile.d/ (at least on a Red Hat system - I don't know about others).



    [pid 60047] open("/home/user/.bashrc", O_RDONLY) = 3
    [pid 60047] open("/etc/bashrc", O_RDONLY) = 3


    The only way I can think of is the above, been quick enough to abort the login process before the scripts are loaded (but not to quick as to abort the session). - You might want to increase the load on the system (if it's possible) to give you more time during the login process.



    ps. if you find the answer useful please mark it






    share|improve this answer























    • nice, this is cool
      – stibi
      Jul 7 '15 at 16:52










    • Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
      – Mark Thomson
      Dec 30 '18 at 23:12














    2












    2








    2






    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced:



    $ ssh -v localhost
    OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
    ........
    Authenticated to localhost ([::1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    Last login: Tue Jul 7 19:46:42 2015 from localhost
    ^C-bash-4.2$




    Edit to clarify a few things:



    When sshd opens a session on the server, it does so by reading the user shell (that is /bin/bash in this case).



    It does not matter whatever option is given on bash or ssh command to run (including sftp). That ssh command (including sftp) or bash option is passed to a bash instance after a session is opened. You have no control on what that instance does. For example:



    client$ ssh localhost bash --noprofile --norc


    strace output on the server:



    [pid 60047] execve("/bin/bash", ["bash", "-c", "bash --noprofile --norc"], [/* 16 vars */]) = 0
    [pid 60047] execve("/usr/bin/bash", ["bash", "--noprofile", "--norc"], [/* 28 vars */]) = 0


    As you can see the ssh command ("bash --noprofile --norc") is passed on the first execve as an argument to "bash" with the "-c" option.



    That first bash instance that you have no control on with read ~/.bashrc which in turn will read /etc/bashrc which will load the scripts under /etc/profile.d/ (at least on a Red Hat system - I don't know about others).



    [pid 60047] open("/home/user/.bashrc", O_RDONLY) = 3
    [pid 60047] open("/etc/bashrc", O_RDONLY) = 3


    The only way I can think of is the above, been quick enough to abort the login process before the scripts are loaded (but not to quick as to abort the session). - You might want to increase the load on the system (if it's possible) to give you more time during the login process.



    ps. if you find the answer useful please mark it






    share|improve this answer














    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced:



    $ ssh -v localhost
    OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
    ........
    Authenticated to localhost ([::1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    Last login: Tue Jul 7 19:46:42 2015 from localhost
    ^C-bash-4.2$




    Edit to clarify a few things:



    When sshd opens a session on the server, it does so by reading the user shell (that is /bin/bash in this case).



    It does not matter whatever option is given on bash or ssh command to run (including sftp). That ssh command (including sftp) or bash option is passed to a bash instance after a session is opened. You have no control on what that instance does. For example:



    client$ ssh localhost bash --noprofile --norc


    strace output on the server:



    [pid 60047] execve("/bin/bash", ["bash", "-c", "bash --noprofile --norc"], [/* 16 vars */]) = 0
    [pid 60047] execve("/usr/bin/bash", ["bash", "--noprofile", "--norc"], [/* 28 vars */]) = 0


    As you can see the ssh command ("bash --noprofile --norc") is passed on the first execve as an argument to "bash" with the "-c" option.



    That first bash instance that you have no control on with read ~/.bashrc which in turn will read /etc/bashrc which will load the scripts under /etc/profile.d/ (at least on a Red Hat system - I don't know about others).



    [pid 60047] open("/home/user/.bashrc", O_RDONLY) = 3
    [pid 60047] open("/etc/bashrc", O_RDONLY) = 3


    The only way I can think of is the above, been quick enough to abort the login process before the scripts are loaded (but not to quick as to abort the session). - You might want to increase the load on the system (if it's possible) to give you more time during the login process.



    ps. if you find the answer useful please mark it







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 7 '15 at 19:33

























    answered Jul 7 '15 at 16:49









    nkmsnkms

    43634




    43634












    • nice, this is cool
      – stibi
      Jul 7 '15 at 16:52










    • Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
      – Mark Thomson
      Dec 30 '18 at 23:12


















    • nice, this is cool
      – stibi
      Jul 7 '15 at 16:52










    • Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
      – Mark Thomson
      Dec 30 '18 at 23:12
















    nice, this is cool
    – stibi
    Jul 7 '15 at 16:52




    nice, this is cool
    – stibi
    Jul 7 '15 at 16:52












    Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
    – Mark Thomson
    Dec 30 '18 at 23:12




    Tip: See @st0ne's supplemental contribution to this answer for a great way to increase your chances of Ctrl+C working.
    – Mark Thomson
    Dec 30 '18 at 23:12













    1














    I had the same problem and finally found a solution.



    As @nkms mentioned:




    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced




    To raise you chances i've used the following loop:



    $ (trap '' INT; while true; do ssh myuser@myserver; done)


    The script starts subshell '(' and deactivates the ctr-c command for that subshell (with the trap command). Then it loops over the ssh command.
    If you continuously press ctrl-c or hold down ctrl-c, you raise you chances to hit the right moment.



    ... works like a charm!






    share|improve this answer

















    • 1




      It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
      – Mark Thomson
      Dec 30 '18 at 23:06












    • @MarkThomson: THX!
      – st0ne
      Jan 4 at 9:38
















    1














    I had the same problem and finally found a solution.



    As @nkms mentioned:




    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced




    To raise you chances i've used the following loop:



    $ (trap '' INT; while true; do ssh myuser@myserver; done)


    The script starts subshell '(' and deactivates the ctr-c command for that subshell (with the trap command). Then it loops over the ssh command.
    If you continuously press ctrl-c or hold down ctrl-c, you raise you chances to hit the right moment.



    ... works like a charm!






    share|improve this answer

















    • 1




      It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
      – Mark Thomson
      Dec 30 '18 at 23:06












    • @MarkThomson: THX!
      – st0ne
      Jan 4 at 9:38














    1












    1








    1






    I had the same problem and finally found a solution.



    As @nkms mentioned:




    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced




    To raise you chances i've used the following loop:



    $ (trap '' INT; while true; do ssh myuser@myserver; done)


    The script starts subshell '(' and deactivates the ctr-c command for that subshell (with the trap command). Then it loops over the ssh command.
    If you continuously press ctrl-c or hold down ctrl-c, you raise you chances to hit the right moment.



    ... works like a charm!






    share|improve this answer












    I had the same problem and finally found a solution.



    As @nkms mentioned:




    You have about 1/3 chance (at least I get 1/3) to interrupt (hit Ctrl+C) the login process before /etc/profile is sourced




    To raise you chances i've used the following loop:



    $ (trap '' INT; while true; do ssh myuser@myserver; done)


    The script starts subshell '(' and deactivates the ctr-c command for that subshell (with the trap command). Then it loops over the ssh command.
    If you continuously press ctrl-c or hold down ctrl-c, you raise you chances to hit the right moment.



    ... works like a charm!







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 8 '18 at 14:53









    st0nest0ne

    1212




    1212








    • 1




      It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
      – Mark Thomson
      Dec 30 '18 at 23:06












    • @MarkThomson: THX!
      – st0ne
      Jan 4 at 9:38














    • 1




      It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
      – Mark Thomson
      Dec 30 '18 at 23:06












    • @MarkThomson: THX!
      – st0ne
      Jan 4 at 9:38








    1




    1




    It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
    – Mark Thomson
    Dec 30 '18 at 23:06






    It worked beautifully for me. Of all the things I've ever learned from this site, this one right here had the most "wow, my butt just got saved!" factor of any of them. Thank you for your clever solution.
    – Mark Thomson
    Dec 30 '18 at 23:06














    @MarkThomson: THX!
    – st0ne
    Jan 4 at 9:38




    @MarkThomson: THX!
    – st0ne
    Jan 4 at 9:38











    0














    Does sftp also fail ? If doesn't, you could make use of that to place a good /etc/profile.d file there.






    share|improve this answer





















    • good idea, but doesn't work either, it fail with "Connection closed"
      – stibi
      Jul 5 '15 at 20:37












    • Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
      – steve
      Jul 5 '15 at 20:44










    • For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
      – stibi
      Jul 5 '15 at 20:46






    • 3




      What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
      – Satō Katsura
      Jul 5 '15 at 20:47










    • scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
      – stibi
      Jul 5 '15 at 22:15
















    0














    Does sftp also fail ? If doesn't, you could make use of that to place a good /etc/profile.d file there.






    share|improve this answer





















    • good idea, but doesn't work either, it fail with "Connection closed"
      – stibi
      Jul 5 '15 at 20:37












    • Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
      – steve
      Jul 5 '15 at 20:44










    • For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
      – stibi
      Jul 5 '15 at 20:46






    • 3




      What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
      – Satō Katsura
      Jul 5 '15 at 20:47










    • scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
      – stibi
      Jul 5 '15 at 22:15














    0












    0








    0






    Does sftp also fail ? If doesn't, you could make use of that to place a good /etc/profile.d file there.






    share|improve this answer












    Does sftp also fail ? If doesn't, you could make use of that to place a good /etc/profile.d file there.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 5 '15 at 20:34









    stevesteve

    13.9k22452




    13.9k22452












    • good idea, but doesn't work either, it fail with "Connection closed"
      – stibi
      Jul 5 '15 at 20:37












    • Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
      – steve
      Jul 5 '15 at 20:44










    • For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
      – stibi
      Jul 5 '15 at 20:46






    • 3




      What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
      – Satō Katsura
      Jul 5 '15 at 20:47










    • scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
      – stibi
      Jul 5 '15 at 22:15


















    • good idea, but doesn't work either, it fail with "Connection closed"
      – stibi
      Jul 5 '15 at 20:37












    • Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
      – steve
      Jul 5 '15 at 20:44










    • For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
      – stibi
      Jul 5 '15 at 20:46






    • 3




      What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
      – Satō Katsura
      Jul 5 '15 at 20:47










    • scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
      – stibi
      Jul 5 '15 at 22:15
















    good idea, but doesn't work either, it fail with "Connection closed"
    – stibi
    Jul 5 '15 at 20:37






    good idea, but doesn't work either, it fail with "Connection closed"
    – stibi
    Jul 5 '15 at 20:37














    Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
    – steve
    Jul 5 '15 at 20:44




    Shucks. Is logging on via the console an option? Or use something other than ssh to logon (telnet, rsh, ftp by any chance?) Or if you've a backup solution like NetBackup, use that to restore a "good" version of the file?
    – steve
    Jul 5 '15 at 20:44












    For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
    – stibi
    Jul 5 '15 at 20:46




    For a console, I'll have to ask the provider of the virtual machine. I'll try the other options, but doubt it...
    – stibi
    Jul 5 '15 at 20:46




    3




    3




    What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
    – Satō Katsura
    Jul 5 '15 at 20:47




    What about scp? It works at a lower level than sftp. Something like scp file root@machine:/etc/profile.d.
    – Satō Katsura
    Jul 5 '15 at 20:47












    scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
    – stibi
    Jul 5 '15 at 22:15




    scp seems to be also invoking bash process, because it fail in the same manner as all the other attempts…
    – stibi
    Jul 5 '15 at 22:15











    0














    I have two problems with your question.



    ps -A|grep bash|wc -l


    and the same command in



    ssh localhost 'csh -l'


    give the same number.



    So it does not seem that a bash is run before 'csh -l'.



    On the other hand csh does not use /etc/profile.



    strace -eopen csh -l



    does not show any entry of /etc/profile*.



    So I am not sure the problem you have is in /etc/profile*.



    Am I missing something?






    share|improve this answer



















    • 1




      the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
      – stibi
      Jul 7 '15 at 16:45










    • So just deleting a script in /etc/profile.d/ solved the problem?
      – Jodka Lemon
      Jul 7 '15 at 16:47










    • Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
      – stibi
      Jul 7 '15 at 16:51
















    0














    I have two problems with your question.



    ps -A|grep bash|wc -l


    and the same command in



    ssh localhost 'csh -l'


    give the same number.



    So it does not seem that a bash is run before 'csh -l'.



    On the other hand csh does not use /etc/profile.



    strace -eopen csh -l



    does not show any entry of /etc/profile*.



    So I am not sure the problem you have is in /etc/profile*.



    Am I missing something?






    share|improve this answer



















    • 1




      the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
      – stibi
      Jul 7 '15 at 16:45










    • So just deleting a script in /etc/profile.d/ solved the problem?
      – Jodka Lemon
      Jul 7 '15 at 16:47










    • Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
      – stibi
      Jul 7 '15 at 16:51














    0












    0








    0






    I have two problems with your question.



    ps -A|grep bash|wc -l


    and the same command in



    ssh localhost 'csh -l'


    give the same number.



    So it does not seem that a bash is run before 'csh -l'.



    On the other hand csh does not use /etc/profile.



    strace -eopen csh -l



    does not show any entry of /etc/profile*.



    So I am not sure the problem you have is in /etc/profile*.



    Am I missing something?






    share|improve this answer














    I have two problems with your question.



    ps -A|grep bash|wc -l


    and the same command in



    ssh localhost 'csh -l'


    give the same number.



    So it does not seem that a bash is run before 'csh -l'.



    On the other hand csh does not use /etc/profile.



    strace -eopen csh -l



    does not show any entry of /etc/profile*.



    So I am not sure the problem you have is in /etc/profile*.



    Am I missing something?







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 7 '15 at 15:25

























    answered Jul 7 '15 at 12:29









    Jodka LemonJodka Lemon

    2,463534




    2,463534








    • 1




      the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
      – stibi
      Jul 7 '15 at 16:45










    • So just deleting a script in /etc/profile.d/ solved the problem?
      – Jodka Lemon
      Jul 7 '15 at 16:47










    • Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
      – stibi
      Jul 7 '15 at 16:51














    • 1




      the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
      – stibi
      Jul 7 '15 at 16:45










    • So just deleting a script in /etc/profile.d/ solved the problem?
      – Jodka Lemon
      Jul 7 '15 at 16:47










    • Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
      – stibi
      Jul 7 '15 at 16:51








    1




    1




    the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
    – stibi
    Jul 7 '15 at 16:45




    the problem is definitelly there, I'm not 100% sure about the root cause, but I'll dig it out. Now I have the server ready and fixed again, provider's support helped me. Once the bloody script was gone, SSH worked again.
    – stibi
    Jul 7 '15 at 16:45












    So just deleting a script in /etc/profile.d/ solved the problem?
    – Jodka Lemon
    Jul 7 '15 at 16:47




    So just deleting a script in /etc/profile.d/ solved the problem?
    – Jodka Lemon
    Jul 7 '15 at 16:47












    Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
    – stibi
    Jul 7 '15 at 16:51




    Yes. Without the script and its "set -euo", the other scripts in profile.d were invoked without problems, even these with unbounded variables…nothing what would cause exiting these "wrong" scripts with non zero status code and thus taking the ssh connection down with them. That's my current exaplanation :)
    – stibi
    Jul 7 '15 at 16:51











    0














    This is unlikely to work, but you could try sending a value for KSH_VERSION when you make the ssh connection:



    KSH_VERSION=x ssh -v -o 'SendEnv=KSH_VERSION' myuser@myserver


    The idea is to set the environment variable to something, so that bash won't complain that it's unset. I say it's unlikely to work because the default SSH server configuration wouldn't permit you to set this particular variable. This would only work if someone had reason to make that setting more lenient on this particular server.






    share|improve this answer





















    • you are correct in all points :) doesn't work, because of the reasons you exaplained
      – stibi
      Jul 7 '15 at 16:44
















    0














    This is unlikely to work, but you could try sending a value for KSH_VERSION when you make the ssh connection:



    KSH_VERSION=x ssh -v -o 'SendEnv=KSH_VERSION' myuser@myserver


    The idea is to set the environment variable to something, so that bash won't complain that it's unset. I say it's unlikely to work because the default SSH server configuration wouldn't permit you to set this particular variable. This would only work if someone had reason to make that setting more lenient on this particular server.






    share|improve this answer





















    • you are correct in all points :) doesn't work, because of the reasons you exaplained
      – stibi
      Jul 7 '15 at 16:44














    0












    0








    0






    This is unlikely to work, but you could try sending a value for KSH_VERSION when you make the ssh connection:



    KSH_VERSION=x ssh -v -o 'SendEnv=KSH_VERSION' myuser@myserver


    The idea is to set the environment variable to something, so that bash won't complain that it's unset. I say it's unlikely to work because the default SSH server configuration wouldn't permit you to set this particular variable. This would only work if someone had reason to make that setting more lenient on this particular server.






    share|improve this answer












    This is unlikely to work, but you could try sending a value for KSH_VERSION when you make the ssh connection:



    KSH_VERSION=x ssh -v -o 'SendEnv=KSH_VERSION' myuser@myserver


    The idea is to set the environment variable to something, so that bash won't complain that it's unset. I say it's unlikely to work because the default SSH server configuration wouldn't permit you to set this particular variable. This would only work if someone had reason to make that setting more lenient on this particular server.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 7 '15 at 16:41









    KensterKenster

    1,4021611




    1,4021611












    • you are correct in all points :) doesn't work, because of the reasons you exaplained
      – stibi
      Jul 7 '15 at 16:44


















    • you are correct in all points :) doesn't work, because of the reasons you exaplained
      – stibi
      Jul 7 '15 at 16:44
















    you are correct in all points :) doesn't work, because of the reasons you exaplained
    – stibi
    Jul 7 '15 at 16:44




    you are correct in all points :) doesn't work, because of the reasons you exaplained
    – stibi
    Jul 7 '15 at 16:44











    0














    I ended up with the same problem, but was installing something else and fixed it once I removed the below:



    /etc/sysctl.conf
    fs.file-max=100000


    Then



    /etc/security/limits.conf:
    * soft nofile 1000000
    * hard nofile 1000000


    Lastly



    /etc/pam.d/common-session:
    session required pam_limits.so





    share|improve this answer








    New contributor




    BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0














      I ended up with the same problem, but was installing something else and fixed it once I removed the below:



      /etc/sysctl.conf
      fs.file-max=100000


      Then



      /etc/security/limits.conf:
      * soft nofile 1000000
      * hard nofile 1000000


      Lastly



      /etc/pam.d/common-session:
      session required pam_limits.so





      share|improve this answer








      New contributor




      BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        0












        0








        0






        I ended up with the same problem, but was installing something else and fixed it once I removed the below:



        /etc/sysctl.conf
        fs.file-max=100000


        Then



        /etc/security/limits.conf:
        * soft nofile 1000000
        * hard nofile 1000000


        Lastly



        /etc/pam.d/common-session:
        session required pam_limits.so





        share|improve this answer








        New contributor




        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I ended up with the same problem, but was installing something else and fixed it once I removed the below:



        /etc/sysctl.conf
        fs.file-max=100000


        Then



        /etc/security/limits.conf:
        * soft nofile 1000000
        * hard nofile 1000000


        Lastly



        /etc/pam.d/common-session:
        session required pam_limits.so






        share|improve this answer








        New contributor




        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 2 hours ago









        BlahnikABlahnikA

        11




        11




        New contributor




        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        BlahnikA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.























            -1














            Try ssh -t username@hostname /bin/sh --noprofile.






            share|improve this answer























            • Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
              – stibi
              Jul 5 '15 at 20:52






            • 1




              And a different shell?
              – Jodka Lemon
              Jul 6 '15 at 16:03










            • ksh, csh…both invoking /etc/profile, no go
              – stibi
              Jul 7 '15 at 6:49










            • What does csh -f?
              – Jodka Lemon
              Jul 7 '15 at 9:49
















            -1














            Try ssh -t username@hostname /bin/sh --noprofile.






            share|improve this answer























            • Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
              – stibi
              Jul 5 '15 at 20:52






            • 1




              And a different shell?
              – Jodka Lemon
              Jul 6 '15 at 16:03










            • ksh, csh…both invoking /etc/profile, no go
              – stibi
              Jul 7 '15 at 6:49










            • What does csh -f?
              – Jodka Lemon
              Jul 7 '15 at 9:49














            -1












            -1








            -1






            Try ssh -t username@hostname /bin/sh --noprofile.






            share|improve this answer














            Try ssh -t username@hostname /bin/sh --noprofile.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 6 '15 at 16:00

























            answered Jul 5 '15 at 20:49









            Jodka LemonJodka Lemon

            2,463534




            2,463534












            • Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
              – stibi
              Jul 5 '15 at 20:52






            • 1




              And a different shell?
              – Jodka Lemon
              Jul 6 '15 at 16:03










            • ksh, csh…both invoking /etc/profile, no go
              – stibi
              Jul 7 '15 at 6:49










            • What does csh -f?
              – Jodka Lemon
              Jul 7 '15 at 9:49


















            • Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
              – stibi
              Jul 5 '15 at 20:52






            • 1




              And a different shell?
              – Jodka Lemon
              Jul 6 '15 at 16:03










            • ksh, csh…both invoking /etc/profile, no go
              – stibi
              Jul 7 '15 at 6:49










            • What does csh -f?
              – Jodka Lemon
              Jul 7 '15 at 9:49
















            Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
            – stibi
            Jul 5 '15 at 20:52




            Tried that, doesn't work, I think it is because there is a main bash process created which is parent to the one started from the ssh command
            – stibi
            Jul 5 '15 at 20:52




            1




            1




            And a different shell?
            – Jodka Lemon
            Jul 6 '15 at 16:03




            And a different shell?
            – Jodka Lemon
            Jul 6 '15 at 16:03












            ksh, csh…both invoking /etc/profile, no go
            – stibi
            Jul 7 '15 at 6:49




            ksh, csh…both invoking /etc/profile, no go
            – stibi
            Jul 7 '15 at 6:49












            What does csh -f?
            – Jodka Lemon
            Jul 7 '15 at 9:49




            What does csh -f?
            – Jodka Lemon
            Jul 7 '15 at 9:49


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f214042%2fcant-login-to-server-with-ssh-because-of-a-script-in-etc-profile-d-exiting-wit%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            サソリ

            広島県道265号伴広島線

            Accessing regular linux commands in Huawei's Dopra Linux