Find the answer to your Linux question:
Results 1 to 7 of 7
Hello, I have created .sh file to login into remote server by using following; # vi vpn.sh ssh rootatremoteserverip then I run sh vpn.sh and it asks password for this ...
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    5

    Creating .sh

    Hello,

    I have created .sh file to login into remote server by using following;

    # vi vpn.sh
    ssh rootatremoteserverip

    then I run sh vpn.sh and it asks password for this server, I want to put the password also in the script so that when I type sh vpn.sh then it won't ask password.

    Any ideas.

    ______
    Regards,
    Ali

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    yes.
    - use ssh authorized keys
    - do not remote login as root
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Jan 2010
    Posts
    5
    Quote Originally Posted by Irithori View Post
    yes.
    - use ssh authorized keys
    - do not remote login as root
    I am using authorized key. I want to put key in vpn.sh so it will not ask me for key when I type sh vpn.sh

  4. #4
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    ok, if authorized keys login is already setup, then you might want to look into ssh-agent.

    The idea is, that you give the passphrase just once (per session).
    You must always face the curtain with a bow.

  5. #5
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,114
    You cannot script an ssh session with a shell script.
    You should use expect

    Manpage of EXPECT

  6. #6
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by smaj84 View Post
    I am using authorized key.
    I'm confused. When I use authorized keys my connection between my computer and the remote host is trusted and doesn't require a password - I thought that was the point of authorized keys?

  7. #7
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    I'm confused. When I use authorized keys my connection between my computer and the remote host is trusted and doesn't require a password - I thought that was the point of authorized keys?
    The private key can and should be protected with a passphrase.
    Otherwise anyone with that file can access your servers.

    But you dont want to type that passphrase all the time.
    This is where the ssh-agent comes in.
    You must always face the curtain with a bow.

Posting Permissions

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