i want to use FreeBSD intro google cloud but i can't make the password work. Sorry for my bad english.
Soo , i have this shell script for create image :
VERSION=10.3-RELEASE
VMSIZE=10g
SWAPSIZE=1G
NEWFS_OPTIONS="-U -j -t"
COMPONENTS="base keel"
TS=`env TZ=UTC date +%Y%m%d%H%M%S`
IMAGENAME=`echo FreeBSD-${VERSION}-i386-${TS} | tr '[A-Z]' '[a-z]' | sed -e 's/.//g'`
BUCKETFILE=FreeBSD-${VERSION}-i386-${TS}.tar.gz
TMPFILE=FreeBSD-${VERSION}-i386-gcloud-image-${TS}.raw
WRKDIR=${PWD}
TMPMOUNT=/mnt/gcloud_new_${TS}
###############################
cleanup() {
set +e
echo "Error or interrupt detected, cleaning up and exiting"
cd ${WRKDIR}
umount -f ${TMPMOUNT} >/dev/null 2>&1
rmdir ${TMPMOUNT} >/dev/null 2>&1
mdconfig -d -u ${MD_UNIT} >/dev/null 2>&1
rm -f ${TMPFILE} disk.raw pmbr gptboot /tmp/mkimg-?????? >/dev/null 2>&1
trap - SIGHUP SIGINT SIGTERM EXIT
echo
exit 1
}
build_mirror() {
cd ${WRKDIR}
mkdir -p ${VERSION}
cd ${VERSION}
for comp in ${COMPONENTS} ; do
if [ ! -f ${comp}.txz ]; then
fetch http://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/${VERSION}/${comp}.txz
fi
done
}
build_image() {
cd ${WRKDIR}
truncate -s ${VMSIZE} ${TMPFILE}
MD_UNIT=$(mdconfig -f ${TMPFILE})
echo " Creating filesystem"
newfs ${NEWFS_OPTIONS} ${MD_UNIT} >/dev/null 2>&1
mkdir -p ${TMPMOUNT}
mount /dev/${MD_UNIT} ${TMPMOUNT}
cd ${TMPMOUNT}
for comp in ${COMPONENTS} ; do
echo " Installing ${comp} into image"
tar -xzf ${WRKDIR}/${VERSION}/${comp}.txz
done
}
setup_image() {
cd ${TMPMOUNT}
chroot . usr/sbin/pw unlock root
echo "ssh_service::0:0::::/usr/share/games/Ira::tEst" | adduser -f -
cat << EOF > etc/resolv.conf
search google.inteal
nameserver 8.8.4.4
nameserver 8.8.8.8
EOF
cat << EOF > etc/fstab
# Custom /etc/fstab for FreeBSD VM images
/dev/gpt/rootfs / ufs rw 1 1
/dev/gpt/swapfs none swap sw 0 0
EOF
cat << EOF > etc/rc.conf
hostname="Ira"
ifconfig_vtnet0="SYNCDHCP mtu 1460"
ntpd_sync_on_start="YES"
sshd_enable="YES"
EOF
cat << EOF > boot/loader.conf
autoboot_delay="-1"
beastie_disable="YES"
loader_logo="none"
hw.memtest.tests="0"
console="comconsole"
hw.vtnet.mq_disable=1
ke.timecounter.hardware=ACPI-safe
aesni_load="YES"
nvme_load="YES"
EOF
cat << EOF >> etc/hosts
169.254.169.254 metadata.google.inteal metadata
EOF
cat << EOF > etc/ntp.conf
server metadata.google.inteal iburst
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 127.127.1.0
EOF
cat << EOF >> etc/syslog.conf
*.err;ke.waing;auth.notice;mail.crit /dev/console
EOF
cat << EOF >> etc/ssh/sshd_config
ChallengeResponseAuthentication no
X11Forwarding no
AcceptEnv LANG
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
AllowAgentForwarding no
PermitRootLogin yes
PasswordAuthentication yes
ChallengeResponseAuthentication yes
ClientAliveInterval 420
EOF
cat << EOF >> etc/crontab
0 3 * * * root /usr/sbin/freebsd-update cron
EOF
cat << EOF >> etc/sysctl.conf
net.inet.icmp.drop_redirect=1
net.inet.ip.redirect=0
net.inet.tcp.blackhole=2
net.inet.udp.blackhole=1
ke.ipc.somaxconn=1024
debug.trace_on_panic=1
debug.debugger_on_panic=0
EOF
sed -E -i '' 's/^([^#].*[[:space:]])on/1off/' etc/ttys
touch ./firstboot
}
finish_image() {
cd ${TMPMOUNT}
cp boot/pmbr ${WRKDIR}
cp boot/gptboot ${WRKDIR}
cd ${WRKDIR}
umount ${TMPMOUNT}
rmdir ${TMPMOUNT}
mdconfig -d -u ${MD_UNIT}
echo " Creating partitioned file"
mkimg -s gpt -b pmbr
-p freebsd-boot/bootfs:=gptboot
-p freebsd-swap/swapfs::${SWAPSIZE}
-p freebsd-ufs/rootfs:=${TMPFILE}
-o disk.raw
rm ${TMPFILE} pmbr gptboot
echo " Creating image tar"
tar --format=gnutar -Szcf ${BUCKETFILE} disk.raw
rm disk.raw
}
###############################
if [ $(id -u) != 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
set -e
trap cleanup SIGHUP SIGINT SIGTERM EXIT
cd ${WRKDIR}
echo "Building mirror of OS components"
build_mirror
echo "Creating image"
build_image
echo "Setting up image"
setup_image
echo "Finishing image"
finish_image
trap - SIGHUP SIGINT SIGTERM EXIT
All is fine, all working perfect. But one issue, i don't want to install all google packages and that things. I want a clean and fresh install then i will configure myself what i need. After i install intro google cloud when i try to login with winscp it says AccesDenied wrong password. My question is.. How i can change this script to make a image with password for root already set? How i can change this shell script to make a new user and new password ? Do you guys have some ideea wich password will assign? Based on this shell script with actual codes wich password will assign for root? I just need to auto set root password or to know wich password will set.
thanks
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 286
تاريخ: چهارشنبه
2 تير
1395 ساعت: 6:24