通过 rsync 发布到自己的远程服务器的方法####
修改 octopress 根目录下的 Rakefile 文件:
ssh_user = "user1@[服务器IP]"
ssh_port = "9981" # 服务器端口
document_root = "/data/wwwroot/"
rsync_delete = true # 同步删除
rsync_args = " --omit-dir-times --no-perms " # 需要指定的 rsync 的参数
rsync 命令出错及解决方法:####
如上部分代码所示,这两个错误已经解决
错误描述 | 在命令中加入参数 |
---|---|
rsync: failed to set permissions on … | --no-perms |
rsync error: failed to set times on “.” Operation not permitted | --omit-dir-times |
SSH 免登录的方式####
这里方法其实网上有很多,anyway 若水三千,只取一瓢,这里纪录是我自己使用的方式,也比较通用
客户机操作步骤:
ssh-keygen -t rsa # 本地生成公私钥
ssh user1@[服务器IP] "mkdir .ssh" # 使用将来要登录到服务器的用户在其 home 目录创建 .ssh 目录,用于存放认证文件
scp ~/.ssh/id_rsa.pub user1@[服务器IP]:.ssh/id_rsa.pub # 将本地公钥文件通过 scp 传输到服务器用户的 .ssh 目录下
服务器操作步骤
touch ~/.ssh/authorized_keys # 生成 authorized_keys (如果不存在的话)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys # 将公钥(id_rsa.pub)的内容复制到 authorized_keys 文件
之后就可以在客户机上使用 ssh user1@[服务器IP]
的方式登陆服务器而无需再输入密码