Find the answer to your Linux question:
Results 1 to 3 of 3
how do i write a shell script to ssh into a remote server with password and run a script in it?...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    3

    shell script to ssh into a remote computer and run a script

    how do i write a shell script to ssh into a remote server with password and run a script in it?

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    In the simplest form, just
    ssh <hostname> <command>

    so, for example:
    Code:
    ssh remotehost.domain.com hostname
    Will return the hostname of remotehost.

    The ssh setup will take care of the authentication, be it password or authorized key.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    You could use sshpass and specify the password on the command line, obs. this is not recommended for security reasons.

    Code:
    sshpass -p 'password' ssh user@host command
    Hope this helps.

Posting Permissions

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