Results 1 to 3 of 3

Thread: .bashrc not executing when logging in using ssh

  1. #1
    Join Date
    Mar 2007
    Location
    Promiseland
    Beans
    1,549
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Question .bashrc not executing when logging in using ssh

    Q1. When accessing a remote system using ssh, is the remote system's .bashrc file supposed to be read/executed?

    I have three systems (when accessed with ssh) where the .bashrc file is acted upon, followed by .bash_aliases which in turn calls a shell script.
    There is a fourth system when I ssh into it from any one of the other three, the .bashrc is not read/executed which makes all of my defined aliases unavailable.

    Q2. Why? Why is .bashrc read/executed when sshing in on three computers, and the .bashrc is not read on the fourth computer?

    All four computers are on the same LAN. All four run the same version of LTS Xubuntu 22.04.3. All four have basically the same version of .bashrc.

    I can not figure out why when using ssh to access the fourth computer, the .bashrc file is not acted upon.
    This is the message that appears on the screen...
    Code:
    hugh@h270m:~$ ssh -x hugh@10.x.x.xxx
    Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.5.0-17-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/pro
    
    Expanded Security Maintenance for Applications is enabled.
    
    0 updates can be applied immediately.
    
    Last login: Mon Feb 12 20:07:36 2024 from 10.x.x.xxx
    hugh@b450m:~$
    Any credible advice is welcome.
    Last edited by him610; February 13th, 2024 at 11:13 PM. Reason: privatized some info
    Cheers,


    The Linux Command Line at http://linuxcommand.org/

  2. #2
    Join Date
    Mar 2007
    Location
    Promiseland
    Beans
    1,549
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: .bashrc not executing when logging in using ssh

    Well, I finally stumbled upon cause and solution.
    I had been reading Bash Guide for Beginners, 3.1.2. Individual user configuration files. In section 3.1.2.1. ~/.bash_profile, it reads, "This is the preferred configuration file for configuring user environments individually. In this file, users can add extra configuration options or change default settings:"

    I compared the listings of ~/.bash* files on each machine. The errant fourth had ~/.bash_profile of zero (0) size none of the other machines had a ~/.bash_profile at all. After removing the zero length ~/bash_profile from the fourth machine, logging out, and then reconnecting using ssh, everything worked as expected.

    Here is the link to where I was reading, https://tldp.org/LDP/Bash-Beginners-...ect_03_01.html
    Cheers,


    The Linux Command Line at http://linuxcommand.org/

  3. #3
    Join Date
    Feb 2024
    Beans
    2

    Re: .bashrc not executing when logging in using ssh

    Thanks for the link, I appreciate you.
    Edit: Solved my issue.
    Last edited by tennysonn; March 8th, 2024 at 10:24 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •