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 [email protected]$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

    The above function is called in a loop varying through a range of IP
    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. 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

    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 [email protected]$1:/usr/local/bin/cron/osx_update
    chmod 600 crontab
    chmod 644 hosts machinelist
    scp -p crontab hosts machinelist [email protected]$1:/etc/crontab

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

  3. Jack Shown

    Warren Oates Guest

    This is quite interesting too:
    Warren Oates, Sep 22, 2009
    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.