---
title: "maven远程发布小记"
author: "agile_boy"
date: "2007-04-01T13:57:18Z"
tags: []
categories: ["企业架构"]
slug: "maven"
draft: false
lastmod: "2007-04-01T13:57:18Z"
id: 67090
url: "https://agile-boy.iteye.com/blog/67090"
---

用maven管理多个工程或者模块，不可避免的要用她的deploy/deploy-file功能，其基本用法在此不再累赘，请参考[maven.apache.org/plugins/maven-deploy-plugin/usage.html](http://maven.apache.org/plugins/maven-deploy-plugin/usage.html)  
  maven支持多种发布协议(URL)，如下

- file:  格式是file://path to repository,是最简单最易用的一种，可惜只能在本机上进行发布
- scp:  格式scp://host/path to repository,是安全文件拷贝的方式，也是maven介绍最多的一种，可惜牵扯到privateKey等问题，到现在还没有搞定 :(
- scpexe: 格式scpexe://host/path to repository,和scp基本类似，不过在这里不是用maven自带的scp处理，而是利用外部的scp命令进行copy,结合ssh的基本信息，尝试成功了 :)
- ftp:  格式ftp://host/path to repository,采用ftp协议的方式进行上传,不过需要扩展插件:wagon-ftp,及相关的common-net等

  下边说说不需要密码的scpexe处理方式，其实其根本还是ssh相关的知识。其步骤如下

1. 在客户机上生成key，
   
   sql 代码
   
   1. ssh-keygen -t rsa -f $HOME/.ssh/id\_rsa -P ''
2. 传送 $HOME/.ssh/id\_rsa.pub到服务器主机上
3. 在服务器用户创建authorized\_keys
   
   sql 代码
   
   1. $ cat id\_rsa.pub &gt;&gt; $HOME/.ssh/authorized\_keys2
   2. $ chmod 0600 $HOME/.ssh/authorized\_keys2
   3. $ cd $HOME/.ssh && ln -s authorized\_keys2 authorized\_keys
4. 用mvn deploy测试或者用ssh user@host测试

   以上操作我在debian linux下边成功