13 Replies Latest reply: Jul 21, 2010 2:51 PM by jarik
tapas_mishra Level 1 Level 1 (10 points)
I added a command alias some=`ssh root@192.168.1.5`

in a file in home directory.I have forgotten the name of file.
If it was .bashrc or .bash_profile so now when ever I am opening a terminal I get a login prompt asking me password of root@192.168.1.5
what can I do to get rid of it.The file how do I locate my Finder window prefernces are to show all file extensions but this one is a hidden file.

I am uploading a snapshot please have lookmy problem right now is I am not able to get the shell see the snapshot here
http://www.flickr.com/photos/48996087@N07/4776570355/

Power PC G5, Mac OS X (10.5.8), 3 GB Ram
  • 1. Re: .bashprofile problem
    BobHarris Level 6 Level 6 (13,120 points)
    Download TextWrangler (free download)
    <http://www.versiontracker.com/dyn/moreinfo/macosx/18529>

    Use TextWrangler -> File -> Open Hidden...
    Navagate to your home folder, and open the .bash_profile (or .bashrc, but I think it will be in .bash_profile).

    Either fix or remove the broken command.

    An alternative to TextWranger would be Smultron (free download)
    <http://www.versiontracker.com/dyn/moreinfo/macosx/24012>
  • 2. Re: .bashprofile problem
    tapas_mishra Level 1 Level 1 (10 points)
    Well Textwrangler did not worked.
    I tried a different thing I did an SSH from a Linux machine the mac in problem.
    And from that I got the same ssh problem but this time Command+C gave me mac's bash shell and I edited the file in problem.Thus got my problem solved.
    Thanks for the help.
  • 3. Re: .bashprofile problem
    BobHarris Level 6 Level 6 (13,120 points)
    I just wondering "How" TextWrangler did not work?

    Or was it I forgot to mention checking the [X] "Show hidden items" box in the file open dialog box? And change the "Enable" to "Everything"?

    Message was edited by: BobHarris
  • 4. Re: .bashprofile problem
    tapas_mishra Level 1 Level 1 (10 points)
    I had done all this when you said hidden files and X it did not worked.It had shown me .bash_profile but it did not opened that to edit.
  • 5. Re: .bashprofile problem
    BobHarris Level 6 Level 6 (13,120 points)
    My bad. I had negleted to mention the

    Enable: Everything

    popup.

    I did some experimentation, and Smultron requires far fewer tricks to just open a hidden file. Smultron (free download)
    <http://www.versiontracker.com/dyn/moreinfo/macosx/24012>

    Smultron -> File -> Open Hidden...

    I am glad you managed to fix your .bash_profile via an ssh login from a different system.
  • 6. Re: .bashprofile problem
    rccharles Level 5 Level 5 (5,360 points)
    Macintosh-HD -> Applications -> Utilities -> Terminal

    # Show hidden files & folders in finder
    defaults write com.apple.finder AppleShowAllFiles TRUE   ;killall Finder
    # Normal display.  Hide hidden files & folders in finder
    defaults write com.apple.finder AppleShowAllFiles FALSE  ;killall Finder


    mac $ pwd
    /Users/mac
    mac $ ls -la .b*
    -rw-------   1 mac  staff  15798 Jul 11 23:32 .bash_history
    -rwx-w--w-   1 mac  staff    265 Dec 27  2009 .bash_profile*
    -rw-r--r--   1 mac  staff    100 May 25  2006 .bashrc
    mac $ pico .bash_profile 
    mac $ 


    Robert
  • 7. Re: .bashprofile problem
    tapas_mishra Level 1 Level 1 (10 points)
    rccharles wrote:
    Macintosh-HD -> Applications -> Utilities -> Terminal

    # Show hidden files & folders in finder
    defaults write com.apple.finder AppleShowAllFiles TRUE   ;killall Finder
    # Normal display.  Hide hidden files & folders in finder
    defaults write com.apple.finder AppleShowAllFiles FALSE  ;killall Finder


    mac $ pwd
    /Users/mac
    mac $ ls -la .b*
    -rw-------   1 mac  staff  15798 Jul 11 23:32 .bash_history
    -rwx-w--w-   1 mac  staff    265 Dec 27  2009 .bash_profile*
    -rw-r--r--   1 mac  staff    100 May 25  2006 .bashrc
    mac $ pico .bash_profile 
    mac $ 


    Robert

    I think you are not getting my problem.I know how to edit in vi or how to see hidden files from finder.
    Have a look again on this snapshot

    http://www.flickr.com/photos/48996087@N07/4776570355/sizes/l/

    As soon as I
    Macintosh-HD -> Applications -> Utilities -> Terminal

    it gave me some thing which above snapshot represents

    Rather than giving a shell (what I got can see at the snapshot) it asked for ssh password of aforesaid machine which later did not existed so opening a terminal I got stuck up with a deadlock as there was no password and until I enter the ssh password as the snapshot says it wont give me shell on local machine.

    I could not type ls cd or pwd even.

    to be able to use
    mac $ pico .bash_profile you need

    mac $

    which I was not getting
    and rather

    ssh root@someIP

    now first you break the deadlock by entering correct password

    then you go to root shell of some machine for which ssh requested but not Mac
    as by this time ssh would have established.

    And local machine you can not type any command on shell
    as it wont let you type until you enter ssh password of remote machine.

    Any of the Command+C etc were also not working for this to come out of ssh and give me a shell and not an ssh password prompt when I click

    terminal to start.
  • 8. Re: .bashprofile problem
    rccharles Level 5 Level 5 (5,360 points)
    Here is Applescript to show hidden files in the finder. Applescript used the sh shell & your unix profiles are not run.

    I'd sudo'd from another account.

    (*
     Name: toggle-hidden
     
     
       Author: rccharles
       
       
       Copyright 2010 rccharles
       GNU General Public License 
       
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation,  version 3
       
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
     
        For a copy of the GNU General Public License see <http://www.gnu.org/licenses/>.
     
       *)
     
    on run
       -- Write a message into the event log.
       log "  --- Starting on " & ((current date) as string) & " --- "
       
       try
          set results to do shell script "defaults read com.apple.finder AppleShowAllFiles"
          log "results = " & results
       on error errorMsg
          -- Most likely, the variable AppleShowAllFiles does not exit.  
          -- AppleShowAllFiles isn't defined in a newly created account. 
          -- The write command below will create the AppleShowAllFiles variable.
          log "Error ..." & errorMsg
          set results to "FALSE"
       end try
       
       if results = "FALSE" then
          display dialog "Displaying all files.  Finder will restart." giving up after 2
          set the_rc to do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE  ;killall Finder"
          
       else
          display dialog "Hiding hidden files.  Finder will restart.." giving up after 2
          
          set the_rc to do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE  ;killall Finder"
          
       end if
       
    end run
  • 9. Re: .bashprofile problem
    reezer Level 1 Level 1 (15 points)
    use vim to edit the file via:

    vi ~/.bash_profile

    to open your file. Hit the "a" key to begin editing and hit ":wq" to save your changes and quit vim. Afterward, use

    source .bash_profile

    to apply the changes you made to the .bash_profile file. Personally, I use similar alias commands in my .bash_profile file, and I am not prompted for a password unless I try to use the command name given on the left hand side of the equal sign.

    In an unrelated note, I would urge you not to logon to a system as root via ssh unless you absolutely have to. I recommend that you logon as a normal user and use "su" or "su -" to get root privileges. In fact, I recommend turning off the ability to logon as root in whatever system you are trying to use as this feature was the recent target of a massive "dumb" attack to gain access to many Linux systems.
  • 10. Re: .bashprofile problem
    BobHarris Level 6 Level 6 (13,120 points)
    use vim to edit the file via:

    vi ~/.bash_profile

    If you read the entire thread, you will see that getting a shell prompt was the problem, as the .bash_profile immediately does an ssh to a remote system.
  • 11. Re: .bashprofile problem
    tapas_mishra Level 1 Level 1 (10 points)
    exactly
  • 12. Re: .bashprofile problem
    reezer Level 1 Level 1 (15 points)
    Apologies for not reading in depth Gents. If the problem has not been resolved...

    I've seen a similar issue before on a Unix system that was caused by a corrupted ".software" user file that was implemented for loading modules.

    The admin solved the issue by logging on to their account (root or other user) and using root privileges to access the user's home directory. Afterword, they were able to fix or restore the .software file for the user and reapplied default permissions.

    I hope this helps.

    Good luck.
  • 13. Re: .bashprofile problem
    jarik Level 4 Level 4 (1,005 points)
    The problem in your alias command is the backquotes - write it with single quotes or double-quotes instead.

    As for getting around the problem of not getting to a command prompt beyond the ssh password prompt: what happens if you just hit enter, doesnt't it give you a shell after three times?

    You could also create a new admin user, open a Terminal as that user and then

    sudo mv ~firstuser/.bashrc ~firstuser/dot-bashrc

    (and the same for .bash_profile and .profile) if you're not comfortable editing the file directly.

    Or get a shell as first user from the second user's Terminal with

    sudo su seconduser -c "bash --norc --noprofile"


    Jari