[shell unix] specify a password in 1 RSH

jebok Posted messages 371 Registration date   Status Member -  
poumiZ Posted messages 103 Status Member -
Hello,

Is it possible to perform an rsh on a remote machine and specify the password on the command line?
In the man, you can only specify the user with the command:
rsh machine -l user


Thank you for your help
Configuration: AIX ksh

4 answers

  1. emateus
     
    The problem is that I can only create scripts on the machine, not access all the directories :/
    Do you have any other tips?
    2
  2. poumiZ Posted messages 103 Status Member 10
     
    insert a .rhosts file on the target machine containing the line:
    <source_machine>

    A bit of documentation (AIX)
    The remote host allows access only if at least one of the following conditions
    is satisfied:

    o The local user ID is not the root user, and the name of the local host is
    listed as an equivalent host in the remote /etc/hosts.equiv file.
    o If either the local user ID is the root user or the check of
    /etc/hosts.equiv is unsuccessful, the remote user's home directory must
    contain a $HOME/.rhosts file that lists the local host and user name.
    0
    1. poumiZ Posted messages 103 Status Member 10
       
      little clarification: create the .rhosts file in the user's $HOME
      0
  3. poumiZ Posted messages 103 Status Member 10
     
    Hello,
    I don't quite understand your problem. One .rhosts file is enough.
    Example:
    SrvA=Local machine
    UsrA=Local user
    SrvB=Remote machine
    UsrB=Remote user

    I'm connected to SrvA with UsrA.
    I want to run a script on SrvB with UsrB.

    What you need to do:
    Create the file /home/UsrB/.rhosts on SrvB (remote machine) with the following content:
    SrvA UsrA <user_local>
    You can add as many lines as you want; in fact, remember to include all known network interfaces (e.g., SrvA2 if you have a second @IP pointing to this alias)

    The hardest part is done, you just need to test it:
    rsh SrvB -l UsrB date
    We should get:
    Thu Jun 14 11:53:45 DFT 2007

    If not OK:
    rshd: 0826-813 Permission is denied.
    0
    1. emateus
       
      For your information, I found an answer to my needs:

      Here it is
      1) Create a script containing the operations we would manually perform
      via telnet. (Example script "script.ksh" following)
      #!/bin/sh
      sleep 2
      echo "login user"
      sleep 1
      echo "password"
      sleep 1
      echo "command 1"
      sleep 1
      echo "command 2"
      sleep 1
      echo "exit"

      Note(1): The "sleep 1" is important on linux platforms
      Otherwise, the script is too fast and telnet does not see
      the instructions go through!
      Increase the sleep value according to the command if it
      has a long response time.
      Note(2): Do not forget to set execute permissions on
      the script (chmod 777 script.ksh)

      2) Then run the script redirected to telnet
      Example:
      #script.ksh|telnet addressIP

      Result: Telnet connection, with the application of the commands 'echo "commandtolaunch"'
      from the script "script.ksh" ("just like manually").

      I thank the internet and all its users.
      0
    2. poumiZ Posted messages 103 Status Member 10
       
      Not bad: we learn something new every day. However, I recommend against the file with chmod 777, as your password is visible to everyone. Chmod 700 is sufficient.
      Thank you
      -1