道德经
红楼梦
经典美文
一些歌曲:亲密爱人
总节一下就是 文字与音乐。
道德经
红楼梦
经典美文
一些歌曲:亲密爱人
总节一下就是 文字与音乐。
ssh-agent是管理多个ssh key的代理,受管理的私钥通过ssh-add来添加
好处1:不用重复输入密码。
用 ssh-add 添加私钥时,如果私钥有密码的话,照例会被要求输入一次密码,在这之后ssh-agent可直接使用该私钥,无需再次密码认证。
好处2:不用到处部署私钥
假设私钥分别可以登录同一内网的主机 A 和主机 B,出于一些原因,不能直接登录 B。可以通过在 A 上部署私钥或者设置 Forwarding 登录 B,也可以转发认证代理连接在 A 上面使用ssh-agent私钥登录 B;可以在A上直接sftp传文件到B上。
如这边有一台机器是local,能通过公钥直接登陆server1和server2。server1和server2之间无公钥登陆。
现在要在server1上直接登陆server2,在local上执行
ssh-agent ssh-add
接下来登陆server1,注意-A
ssh -A server1
可以发现server1上多了/tmp/ssh-xxxxxxxxx/agent.xxxxx的socket,之后神奇的事发生了,在server1上可直接进server2,只需执行如下命令,如果加了-A则可以继续ssh forwarding,以至无限的机器forwarding。
ssh (-A) server2
同样的原理可以试一下sftp, scp等基于ssh的命令。
如运行ssh-add,遇到“Could not open a connection to your authentication agent.”。
解决:需要ssh-agent启动bash,或者说把bash挂到ssh-agent下面。
eval "$(ssh-agent -s)" ssh-add
list the agent managed identities
ssh-add -l
delete all agent managed identities
ssh-add -D
参考:
http://www.cnblogs.com/cheche/archive/2011/01/07/1918825.html
http://blog.pkufranky.com/2012/08/ssh-agent-forwarding-guide/
http://blog.jobbole.com/33790/
背景:
在centos下已经按yum方式安装了apache和subversion, mod_dav_svn
因为yum最新稳定版只有1.6.x,最新版本为1.8.x。所以现在需要对yum安装的subversion进行升级。
首先卸载mod_dav_svn,因为它是旧的mod_dav_svn.so和mod_authz_svn.so
yum -e mod_dav_svn
下载subversion1.8.3
http://subversion.apache.org/download/#recommended-release
需要安装httpd-devel
yum install httpd-devel
解压,编译
./configure --with-apxs=/usr/sbin/apxs
make && make install
到/usr/local/libexec,将mod_svn_dav.so和mod_authz_svn.so复制到/etc/httpd/modules/下,确认apache配置文件中有如下两行:
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
新安装的一系列svn bin文件在/usr/local/bin/svn,确认安装的subversion版本
svn --version svnadmin --version
至此subversion升级完成。
使用vim 无意中又按了一下CTRL+S,vim表现是按任何键都没有用。
问题的原因: CTRL+S表示停止向终端输出; CTRL+Q恢复向终端输出.
Ctrl-S is scroll-lock on, and Ctrl-Q is scroll lock off.
http://pve.proxmox.com/wiki/OpenVZ_Console
主要命令为vzlist, vzctl, vzdump, vzrestore
查看所有已经开启的虚拟机
vzlist
查看全部,关闭的虚拟机
-a, –all list all containers
-S, –stopped list stopped containers
创建id号为1000,模板为centos-5,配置文件为basic,ip地址为192.168.1.200
vzctl create 1000 --ostemplate centos-5 --config basic vzctl set 1000 --ipadd 192.168.1.200 --save vzctl start 1000
删除id号为110的虚拟机
vzctl destroy 110
限制cpu和pty的To set number of processes barrier/limit to 80/100, and PTY barrier/limit to 16/20 PTYs:
vzctl set 1000 --numproc 80:100 -t 16:20 --save
在id号为1000的虚拟机中执行ls -la
vzctl exec 1000 'ls -la / | sort'
进入id号为108的虚拟机
vzctl enter 108
进入到id号为1000的虚拟机同时执行apt-get install vim,不会自动退出
vzctl enter 1000 --exec apt-get install vim
需要自动退出可使用
vzctl enter 1000 --exec "apt-get install vim && logout"
vzctl enter 1000 --exec "apt-get install vim ; logout"
关闭虚拟机
vzctl stop 1000
进入到虚拟机内部查看虚拟机信息
/proc/vz/veinfo
/proc/vz/vestat
vimtutor是一个教程,教人学习使用vim,里面有一句很重要的话
NOTE: As you go through this tutor, do not try to memorize, learn by usage.
NOTE: Remember that you should be learning by doing, not memorization.
vim属于工具,要以动手操作为学习目的,而不是去记忆。
整理一下以前不清晰和新学到的知识点。
Lesson 1.5: TEXT EDITING – APPENDING
** Press A to append text. ** 按大写的A,光标移动到当前行最后并切换到插入模式
Lesson 2.1: DELETION COMMANDS
** Type dw to delete a word. ** 将光标移动到一个单词的开头字母,按下dw,删除当前单词及词后空格。
Lesson 2.2: MORE DELETION COMMANDS
** Type d$ to delete to the end of the line. **按下d$,删除从光标位置到行尾的所有字
Lesson 2.3: ON OPERATORS AND MOTIONS
vim中很多修改命令是遵从 操作+动作 的。删除即:
d motion
那么
d – 表示删除
motion – 动作
以下三个是动作
w – 删除当前光标至下一个单词之前的字符
e – 删除当前光标至当前词的末字符
$ – 删除从光标位置到行尾的所有字符
NOTE:可以发现如果不按d,则w表示跳到下一个单词的首字符,e表示跳到单词的尾字符,$表示跳到行尾。加数字表示计数,如3w会跳到后面第三个词的首字母,d3w表示删除三个单词。
Lesson 2.7: THE UNDO COMMAND
** Press u to undo the last commands, U to fix a whole line. ** 小u是撤销操作,大U是恢复当前行到初始状态。CTRL-R表示重做,即undo the undo’s.
Lesson 3.1: THE PUT COMMAND
** Type p to put previously deleted text after the cursor. **小p表示put之前操作过(删除,复制)的字符,当然也可以认为是paste。按p,“字符”会被放在光标的后面,“行”会放在当前行的下面。
Lesson 3.2: THE REPLACE COMMAND
** Type rx to replace the character at the cursor with x . **按rx表示替换光标的字符为x。按大写的R会从当前字符替换,输入完成后按esc退出替换状态,详见Lesson 6.3: ANOTHER WAY TO REPLACE
Lesson 3.3: THE CHANGE OPERATOR
** To change until the end of a word, type ce . **按ce会删除当前光标到词尾的字符并切换到插入模式。同样可以使用c$, cw, c3w等操作。
Lesson 4.1: CURSOR LOCATION AND FILE STATUS
** Type CTRL-G to show your location in the file and the file status.
Type G to move to a line in the file. **CTRL-G显示当前位置的信息,光标的行列等。
Lesson 4.2: THE SEARCH COMMAND
** Type / followed by a phrase to search for the phrase. **搜索方法是/word,如果向下搜索使用小n,向上搜索使用大N;使用?搜索与使用/搜索正好相反。光标在搜索时跳到不同位置,要回到上一位置按CTRL-O 到下一位置按CTRL-I.
Lesson 4.3: MATCHING PARENTHESES SEARCH
** Type % to find a matching ),], or } . **按%跳到),],}的配对。
Lesson 4.4: THE SUBSTITUTE COMMAND
** Type :s/old/new/g to substitute ‘new’ for ‘old’. **替换
#,#s/old/new/g 从第几行,到第几行将old替换为new
%s/old/new/g 替换全部文件的old为new
%s/old/new/gc 在全文件中替换,每一次替换会有提示要求确认。
Lesson 5.1: HOW TO EXECUTE AN EXTERNAL COMMAND
** Type :! followed by an external command to execute that command. **执行:!+shell命令+回车 会执行命令,就不用退出vim再执行命令了。
Lesson 5.3: SELECTING TEXT TO WRITE
** To save part of the file, type v motion :w FILENAME **保存部分文件,先按v,选取需要的行,然后按:w ttt,保存为ttt
Lesson 5.4: RETRIEVING AND MERGING FILES
** To insert the contents of a file, type :r FILENAME **读取文件并插入到文档中,按:r filename会将filename的内容插入到当前文档中。:r !ls表示将ls的结果插入到文档中。
Lesson 6.5: SET OPTION
** Set an option so a search or substitute ignores case **vim中使用“/”搜索,设置搜索高亮(hlsearch)和忽视大小写(ignore case)
:set hls 搜索高亮
:set nohlsearch 搜索不高亮
:set ic 忽视大小写
:set noic 不忽视大小写
/abc\c 如果只搜索搜索一次,使用\c表示忽视大小写
‘ic’ ‘ignorecase’ 忽略大小写
‘is’ ‘incsearch’ 显示与搜索字符串部分匹配的字符串
‘hls’ ‘hlsearch’ 高亮所有匹配字符串
Lesson 7.1: GETTING HELP
** Use the on-line help system **获取帮助,输入 :help <ENTER>
使用CTRL-W在vim的不同窗口切换,使用:q退出当前窗口。 可以直接使用“:help 条目”的格式
:help w
:help c_CTRL-D
:help insert-index
:help user-manual
vim还有更多的设置在vimrc中。