transferring files to /etc and /usr/local/bin via bash script on 10.5

Discussion in 'Apple' started by Jack Shown, Sep 22, 2009.

  1. Jack Shown

    Jack Shown Guest

    Is it possible to sftp files to remote Macs in which I have the the
    admin password?

    Below is a snippet from my script but it does not succeed because of
    permission problems
    (i.e. not being root).

    admin_sftp() {
    sftp admin@$1 << EOF
    cd /usr/local/bin/cron
    put osx_update
    chmod 700 osx_update
    cd /etc
    put crontab
    chmod 600 crontab
    put hosts
    chmod 644 hosts
    put machinelist
    chmod 644 machinelist
    quit
    EOF
    }

    The above function is called in a loop varying through a range of IP
    addresses
    to which I want to distribute files. However, since the files are
    owned by root,
    the file transfer does not succeed. No root user is enabled other
    than by sudo.
    Is there a way to do this right?

    Thx. Jack
     
    Jack Shown, Sep 22, 2009
    #1
    1. Advertisements

  2. Jack Shown

    Bob Harris Guest

    <
    The files in question are owned or controlled by 'root', and until
    the admin does an 'sudo' the admin is working in 'mortal' mode.

    You could give the 'root' account a password, which would then
    enable 'root' login

    sudo passwd root
    password: your admin password here
    Changing password for root.
    New password:
    Retype new password:

    -OR- Instead of enabling the root account, you could instead,
    create an ssh key and put that in the root's authorized_keys file

    ssh-keygen
    copy the $HOME/.ssh/*.pub file to the other system.
    Store the .pub file in the root account's
    .ssh/authorized_keys file
    Then you should not need to know the root account's password.

    Now you can use sftp or even better scp to copy files into
    directories owned by 'root'

    chmod 700 osx_update
    scp -p osx_update root@$1:/usr/local/bin/cron/osx_update
    chmod 600 crontab
    chmod 644 hosts machinelist
    scp -p crontab hosts machinelist root@$1:/etc/crontab

    Bob Harris
     
    Bob Harris, Sep 22, 2009
    #2
    1. Advertisements

  3. Jack Shown

    Warren Oates Guest

    This is quite interesting too:

    http://www.bombich.com/mactips/rsync.html
     
    Warren Oates, Sep 22, 2009
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.