利用scp自动输入密码进行文件远程拷贝或备份
[ 2010/09/02 22:13 | by admin ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
要求:把192.168.0.3机上的/aa.tar.gz拷贝到192.168.0.2机器的/目录
具体操作:
在备份服务器上192.168.0.2
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
在被备份服务器上192.168.0.3
mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
ssh 192.168.0.2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
在备份服务器上192.168.0.2
scp -rp root@192.168.0.3:/aa.tar.gz /
第一次执行会让输入确认"yes",以后就不用再输入了
此时可以把此命令放到计划任务中而自动执行了
crontab -e
本文来自http://blog.gsywx.com
要求:把192.168.0.3机上的/aa.tar.gz拷贝到192.168.0.2机器的/目录
具体操作:
在备份服务器上192.168.0.2
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
在被备份服务器上192.168.0.3
mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
ssh 192.168.0.2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
在备份服务器上192.168.0.2
scp -rp root@192.168.0.3:/aa.tar.gz /
第一次执行会让输入确认"yes",以后就不用再输入了
此时可以把此命令放到计划任务中而自动执行了
crontab -e
proftpd的安装脚本
[ 2010/09/02 10:16 | by admin ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
程序可以从官方下载
下载地址:
http://www.proftpd.org/
默认约定:
程序安装位置为 :/web/proftpd
创建用户为 :www
www家目录为 :/home/wwwroot/htdocs
www密码在安装过程中手工输入
脚本代码如下:
#!/bin/bash
clear
echo "----------------proftpd安装程序,按任意键继续---------------"
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
char=`get_char`
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.3a.tar.gz
tar zxvf proftpd-1.3.3a.tar.gz
cd proftpd-1.3.3a
./configure --prefix=/web/proftpd
make
make install
mkdir -p /home/wwwroot/htdocs
groupadd www
useradd www -g www -d /home/wwwroot/htdocs -s /sbin/nologin
echo "Please input new password for user: www"
passwd www
chown -R www.www /home/wwwroot/htdocs
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
sed -i 's\PATH="$PATH:/usr/local/sbin"\PATH="$PATH:/web/proftpd/sbin"\g' /etc/rc.d/init.d/proftpd
chmod +x /etc/rc.d/init.d/proftpd
chkconfig --add proftpd
chkconfig proftpd on
cd ../
mv /web/proftpd/etc/proftpd.conf /web/proftpd/etc/proftpd.conf.bak
cp proftpd.conf /web/proftpd/etc/
service proftpd start
echo "删除安装临时文件.............."
rm -Rf proftpd-1.3.3a
echo
echo
echo " ------------------- 如需增加新用户,请使用以下命令 -------------------"
echo "| useradd 用户名 -g 用户组 -d 用户家目录 -s /sbin/nologin |"
echo " -------------------------- proftpd 安装结束! -------------------------"
echo
echo
echo
echo
安装过程中的proftpd.conf为直接拷贝,请先行在安装目录创建profptd.conf,代码如下:
本文来自http://blog.gsywx.com
程序可以从官方下载
下载地址:
http://www.proftpd.org/
默认约定:
程序安装位置为 :/web/proftpd
创建用户为 :www
www家目录为 :/home/wwwroot/htdocs
www密码在安装过程中手工输入
脚本代码如下:
#!/bin/bash
clear
echo "----------------proftpd安装程序,按任意键继续---------------"
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
char=`get_char`
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.3a.tar.gz
tar zxvf proftpd-1.3.3a.tar.gz
cd proftpd-1.3.3a
./configure --prefix=/web/proftpd
make
make install
mkdir -p /home/wwwroot/htdocs
groupadd www
useradd www -g www -d /home/wwwroot/htdocs -s /sbin/nologin
echo "Please input new password for user: www"
passwd www
chown -R www.www /home/wwwroot/htdocs
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
sed -i 's\PATH="$PATH:/usr/local/sbin"\PATH="$PATH:/web/proftpd/sbin"\g' /etc/rc.d/init.d/proftpd
chmod +x /etc/rc.d/init.d/proftpd
chkconfig --add proftpd
chkconfig proftpd on
cd ../
mv /web/proftpd/etc/proftpd.conf /web/proftpd/etc/proftpd.conf.bak
cp proftpd.conf /web/proftpd/etc/
service proftpd start
echo "删除安装临时文件.............."
rm -Rf proftpd-1.3.3a
echo
echo
echo " ------------------- 如需增加新用户,请使用以下命令 -------------------"
echo "| useradd 用户名 -g 用户组 -d 用户家目录 -s /sbin/nologin |"
echo " -------------------------- proftpd 安装结束! -------------------------"
echo
echo
echo
echo
安装过程中的proftpd.conf为直接拷贝,请先行在安装目录创建profptd.conf,代码如下:
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "Welcome to my Proftpd"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#欢迎登录 ProFTPD
DefaultRoot ~
# Normally, we want files to be overwriteable.
#允许被写入覆盖
AllowOverwrite on
#下载允许断点续传
AllowRetrieveRestart on
#上传允许断点续传
AllowStoreRestart on
UseReverseDNS off
IdentLookups off
#设置ftp登陆欢迎信息文件
#DisplayLogin welcome.msg
#屏蔽服务器版本信息
#ServerIdent off
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
#以上为全局配置
#以下为具体目录权限配置
<Directory /home/wwwroot/htdocs/>
<Limit SITE_CHMOD>
AllowAll
</Limit>
AllowRetrieveRestart on
AllowOverwrite on
AllowStoreRestart on
</Directory>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<Anonymous ~ftp>
# User ftp
# Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
# MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
# DisplayLogin welcome.msg
# DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
# DenyAll
# </Limit>
#</Anonymous>
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "Welcome to my Proftpd"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#欢迎登录 ProFTPD
DefaultRoot ~
# Normally, we want files to be overwriteable.
#允许被写入覆盖
AllowOverwrite on
#下载允许断点续传
AllowRetrieveRestart on
#上传允许断点续传
AllowStoreRestart on
UseReverseDNS off
IdentLookups off
#设置ftp登陆欢迎信息文件
#DisplayLogin welcome.msg
#屏蔽服务器版本信息
#ServerIdent off
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
#以上为全局配置
#以下为具体目录权限配置
<Directory /home/wwwroot/htdocs/>
<Limit SITE_CHMOD>
AllowAll
</Limit>
AllowRetrieveRestart on
AllowOverwrite on
AllowStoreRestart on
</Directory>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<Anonymous ~ftp>
# User ftp
# Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
# MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
# DisplayLogin welcome.msg
# DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
# DenyAll
# </Limit>
#</Anonymous>
linux忘记mysql的root密码密码重设脚本
[ 2010/09/01 16:17 | by admin ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
把以下内容保存为:reset_mysql_passwd.sh
并加上可执行权限:chmod +x reset_mysql_passwd.sh
执行即可:./reset_mysql_passwd.sh
默认约定:此时mysqld已经安装为服务,如果未装为服务,需修改脚本内容后运行。
#!/bin/bash
clear
echo "默认约定:mysqld已安装为服务,如不是请修改程序后再执行"
echo
echo "请输入mysql安装路径(如:/web/mysql):"
read -p "mysql路径: " mysqldir
echo
echo "请输入要重设的mysql的root帐户的密码:"
read -p "root新密码: " newpwd
echo
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$newpwd');" > /temp.txt
service mysqld stop
$mysqldir/bin/mysqld_safe --init-file=/temp.txt &
$mysqldir/bin/mysqladmin shutdown -uroot -p$newpwd 2>/dev/null;
sleep 5
service mysqld start
rm -Rf /temp.txt
echo
echo "密码已被重设为:"$newpwd ",程序自动退出!"
本文来自http://blog.gsywx.com
把以下内容保存为:reset_mysql_passwd.sh
并加上可执行权限:chmod +x reset_mysql_passwd.sh
执行即可:./reset_mysql_passwd.sh
默认约定:此时mysqld已经安装为服务,如果未装为服务,需修改脚本内容后运行。
#!/bin/bash
clear
echo "默认约定:mysqld已安装为服务,如不是请修改程序后再执行"
echo
echo "请输入mysql安装路径(如:/web/mysql):"
read -p "mysql路径: " mysqldir
echo
echo "请输入要重设的mysql的root帐户的密码:"
read -p "root新密码: " newpwd
echo
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$newpwd');" > /temp.txt
service mysqld stop
$mysqldir/bin/mysqld_safe --init-file=/temp.txt &
$mysqldir/bin/mysqladmin shutdown -uroot -p$newpwd 2>/dev/null;
sleep 5
service mysqld start
rm -Rf /temp.txt
echo
echo "密码已被重设为:"$newpwd ",程序自动退出!"
mysql-5.1.50-linux-i686-glibc23.tar.gz包的安装方法
[ 2010/08/30 21:08 | by admin ]
mysql-5.1.50-linux-i686-glibc23.tar.gz包的安装
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
习惯于编译安装tar.gz,顺便也学下官方下载的glibc包的安装方法
一、下载源程序
地址:http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/
比如我这里下载的是:mysql-5.1.50-linux-i686-glibc23.tar.gz
mkdir /file/
cd /file/
wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.50-linux-i686-glibc23.tar.gz
二、安装
tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz
cp -rf mysql-5.1.50-linux-i686-glibc23 /usr/local/
cd /usr/local/
mv mysql-5.1.50-linux-i686-glibc23/ mysql
安装为默认的路径,这样就不用为程序目录做软链接了
groupadd mysql
useradd -g mysql mysql
cd mysql/
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's/log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
sed -i 's/binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
sed -i 's/skip-locking/skip-locking\nmax_connections = 1000\nwait_timeout = 5/g' /etc/my.cnf
接下来初始化数据库
scripts/mysql_install_db --user=mysql
安装mysql服务控制
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
bin/mysqladmin -u root password 123654
就这么简单,比编译安装省时不少
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
习惯于编译安装tar.gz,顺便也学下官方下载的glibc包的安装方法
一、下载源程序
地址:http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/
比如我这里下载的是:mysql-5.1.50-linux-i686-glibc23.tar.gz
mkdir /file/
cd /file/
wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.50-linux-i686-glibc23.tar.gz
二、安装
tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz
cp -rf mysql-5.1.50-linux-i686-glibc23 /usr/local/
cd /usr/local/
mv mysql-5.1.50-linux-i686-glibc23/ mysql
安装为默认的路径,这样就不用为程序目录做软链接了
groupadd mysql
useradd -g mysql mysql
cd mysql/
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's/log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
sed -i 's/binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
sed -i 's/skip-locking/skip-locking\nmax_connections = 1000\nwait_timeout = 5/g' /etc/my.cnf
接下来初始化数据库
scripts/mysql_install_db --user=mysql
安装mysql服务控制
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
bin/mysqladmin -u root password 123654
就这么简单,比编译安装省时不少