[Help] AppleScript: SSH password

Discussion in 'Mac Programming' started by iBroken, Aug 14, 2011.

  1. iBroken macrumors newbie

    Joined:
    Jul 17, 2011
    #1
    Hi

    i've to connect to some servers through SSH daily, and every server has his IP and user and pass,and this is how i connect to SSH {xxx=ip}

    open Terminal :

    # ssh root@xxx.xx.xxx.xxx
    # root@xxx.xx.xxx.xxx's password: { then i've to write the password here}

    what i wanna ask about is how to make the script write the password ? i know its n00b question but i'm new to this and the whole Mac :D

    here's my "too Long" script :p

    PHP:
    tell application "Terminal"
        
    do script "ssh root@xxx.xx.xxx.xxx"
    end tell
    thanks
     
  2. res1233 macrumors 65816

    res1233

    Joined:
    Dec 8, 2008
    Location:
    Brooklyn, NY
  3. crackpip macrumors regular

    Joined:
    Jul 23, 2002
    #3
    A more secure solution is to use public key authentication along with ssh-agent (or gpg-agent). You start an instance of ssh-agent, attach keys to it and then you can login without being continually prompted for passwords. You won't have to hardcode your password into the script.

    crackpip
     
  4. iBroken thread starter macrumors newbie

    Joined:
    Jul 17, 2011
    #4
    where exactly i should write this :( , sorry i'm new to this

    sounds too complicated for me :D
     
  5. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    I'm scared that you have root access to servers.
     
  6. iBroken thread starter macrumors newbie

    Joined:
    Jul 17, 2011
    #6
    yeah i do and they are linux, and i'm not that good with it but i can do some things that i need to do :)
     
  7. res1233 macrumors 65816

    res1233

    Joined:
    Dec 8, 2008
    Location:
    Brooklyn, NY
    #7
    You type it where you typed it the first time: after the SSH. Just add :password before the @.
     
  8. iBroken, Aug 14, 2011
    Last edited: Aug 15, 2011

    iBroken thread starter macrumors newbie

    Joined:
    Jul 17, 2011
    #8
    you mean like FTP URL ? if you don't want to be asked about the user and pass you write

    PHP:
    ssh user:pass@xx.xx.xx.xx
    . ??? i tried that before i open this thread but its not working, cuz the SSH will consider it as part of the user :)
     
  9. iBroken thread starter macrumors newbie

    Joined:
    Jul 17, 2011
    #9
    thank you for telling me about this method cuz i googled it and did it :) now i don't need to type passwords anymore :)
     

Share This Page