[wellylug] ssh scripting
michael at diaspora.gen.nz
michael at diaspora.gen.nz
Sat May 21 09:12:29 NZST 2005
Jamie Baddeley writes:
>Is it possible to script ssh commands?
>
>i.e. write a shell script like this:
>
>---------
>#!/usr//bin/ssh host.domain.co.nz
>df -h
As Ewen has posted, that doesn't work for me either (I get "bash:
./filename: No such file or directory", for reasons I can't fathom).
I do have a shell script set up to copy "my stuff" (ie, set up
authorized_keys, and make sure the profile looks roughly right) to a
new machine, though, viz:
#!/bin/sh
host=$1
cat .ssh/authorized_keys | ssh michaelr@$host '
mkdir -p $HOME/.ssh
chmod 0700 $HOME/.ssh
echo "set showmode wm=10 sw=4 tabstop=8 ai" > $HOME/.exrc
cat > $HOME/.ssh/authorized_keys
chmod 0600 $HOME/.ssh/authorized_keys
rm -f $HOME/.bash_profile $HOME/.bashrc $HOME/.bash_login
h=`hostname`
cat > $HOME/.profile <<EOF
PAGER=less
LESS=-smeX
PS1="$h\$ "
ls() { command ls -F $@; }
export PAGER LESS
EOF
'
More information about the wellylug
mailing list