#!/bin/sh if [ "$1"x = ""x ]; then echo "usage:/opt/bin/auto-ssh.sh user server" else user=$1 server=$2 pubkey=`cat ~/.ssh/id_rsa.pub` if [ "$pubkey"x = ""x ]; then ssh-keygen pubkey=`cat ~/.ssh/id_rsa.pub` fi cmd="mkdir -p ~/.ssh && chmod 700 ~/.ssh && [ ! -e \‘~/.ssh/authorized_keys\‘ ] && touch ~/.ssh/authorized_keys&&echo \"$pubkey\" >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" ssh [email protected]$server \`$cmd\` fi
时间: 2024-10-25 21:59:10