May 26
鉴于受服务器被黑的影响,为了增强安全性,打算取消密码登录的方式,改用 Key 登录。不过查了一圈中文的帮助,实在无法理解为什么这么简单的东西就没人能写的让人看明白。下面附上浅显易懂的英文教程一份,3 分钟搞定。
OpenSSH Public Key Authentication
主要流程是自己在本机使用 ssh-keygen 生成好密码,然后上传到服务器上相应帐户的 .ssh/id_dsa.pub 然后将其改成 .ssh/authorized_keys,然后从本机 ssh 过去就可以了,当然需要修改下 /etc/ssh/sshd_config 文件,为了保证安全把端口和允许密码认证都给改了,这样就算再多的 SSH brute force attempts 应该都没什么效果了。
May 09
If you have a dedicated server online can be connected via SSH, you are really lucky. Get tired to search for a workable proxy to access the blocked site? There is a way via the powerful SSH.
Geek to Live: Encrypt your web browsing session (with an SSH SOCKS proxy)
But, if you are a facebook application developer, you must feel very painful to debug the application. Because it requires your application can be accessed by facebook servers, at least you should have public IP address or forwarding the traffic from your router.
Anyway, the problem can be easily solved. Thanks to my friend Wang Chun, he found a way to use SSH creates a tunnel that forwards traffic from server to the client. AWESOME!!
You can use option -R to listen on the port of server and forward the traffic to client.
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side. This works by allocating
a socket to listen to port on the remote side, and whenever a connection is made to this port, the connection is forwarded over the secure channel,
and a connection is made to host port hostport from the local machine.
Port forwardings can also be specified in the configuration file. Privileged ports can be forwarded only when logging in as root on the remote
machine. IPv6 addresses can be specified by enclosing the address in square braces or using an alternative syntax:
[bind_address/]host/port/hostport.
By default, the listening socket on the server will be bound to the loopback interface only. This may be overriden by specifying a bind_address.
An empty bind_address, or the address `*', indicates that the remote socket should listen on all interfaces. Specifying a remote bind_address will
only succeed if the server's GatewayPorts option is enabled (see sshd_config(5)).
Don’t forget to enable ‘GatewayPorts’ in the /etc/ssh/sshd_config.
Enjoy!
Feb 19
今天总算让 Mylyn 和 Trac 一起工作了,需要给 Trac 安上 XmlRpcPlugin,安装还算简单,但是注意 Trac 0.11b1 的兼容性有问题,我打了一个 patch 才正确工作的。再此附上截图一张。:)

Dec 22
今天又重新读了 The C10K Problam,决定好好写份摘要记录下学到的内容。
文章主要探讨了如何配置操作系统或者编写相应的程序可以支持10K数量级以上的客户端。目前有不少IO框架可供选择使用,譬如重量级的ACE,轻量级的libevent等。
I/O 策略
开发网络应用一般有一些好的I/O策略可以参考:
- 是否以及如何在单线程里面处理多I/O调用
- 完全不使用阻塞和同步调用,尽可能使用多进程和多线程实现并发
- 使用非阻塞(non-blocking)调用开始I/O操作(write()系统调用设置O_NONBLOCK参数),使用readiness notification(poll或者/dev/poll)来确定何时启动下一个I/O通道。当然这只能在网络I/O环境下有效。
- 使用异步调用(如aio_write())开始I/O操作,使用completion notification(信号或者completion ports)来获取I/O完成的时间。在网络I/O和磁盘I/O都有好处。
- 如何编写服务客户端的代码
- 为每一个客户端准备一个进程(自1980年以来经典的UNIX方式)
- 每个OS级别的线程服务多客户端,每个客户端收以下方式控制:
- user-level 用户级别线程(例如GUN state线程,经典的Java绿色线程)
- 状态机
- continuation
- 为每个客户端准备一个OS级别线程(例如native方式的Java线程)
- 为每个活跃客户端准备一个OS级别线程(例如使用Apache做前端的Tomcat,NT completion ports,线程池)
- 是否使用标准的I/O服务,或者将一些代码移至内核(例如自定义驱动,内核模块或者VxD)
Level triggered & Edge triggered
采用哪种通知机制非常关键,主要有两种readiness notification类型,基于level-triggered的方式有传统的select()和poll()系统调用,level-triggered针对file descriptors的condition改变进行通知,一旦condition出现变化,那么用select()系统调用会检测到。而edge-triggered这个概念在BSDCON 2000大会上关于kqueue()的论文里面由Jonathon Lemon提出的,和level-triggered不同的是,这种通知不取决于condition的改变,而是取决于事件源的活动。
下面是引自 Kqueue 这篇论文里面的说明:
Events will normally considered to be “level-triggered”, as opposed to “edge-triggered”. Another way of putting this is to say that an event is be reported as long as a specified condition holds, rather than when activity is actually detected from the event source. The given condition could be as simple as “there is unread data in the buffer”, or it could be more complex. This approach handles the scenario described above, and allows the application to perform a partial read on a buffer, yet still be notified of an event the next time it calls the API. This corresponds to the existing semantics provided by poll() and select().
Dec 09
用上了心爱的 MacBook Pro 之后在键位的问题上最让人头疼的就是没有 forward delete 键,在 PC 键盘 backspace 的位置上是 delete 键,但功能缺非如此,不过还是有办法搞定的!
有个叫做 DoubleCommand 的工具可以重新映射键盘按键功能,哈哈,大家都知道该把哪个键改一下映射了吧。正是空格右侧的那个 enter 键,正好当 forward delete 使。
从 http://doublecommand.sourceforge.net/index.html 这里下载 Double Command,下载安装之后在 System Preferences 里面会多一项的,按照下面的截图修改一下。

Recent Comments