Browse files

add the forward-agent configuration directive

  • Loading branch information...
1 parent 6417d9b commit 510f7ab90033c4b7dc9a1483c198208f6d169c4f @bronson bronson committed Apr 27, 2012
Showing with 32 additions and 22 deletions.
  1. +16 −8 Readme.md
  2. +16 −14 bin/deploy
View
24 Readme.md
@@ -53,7 +53,7 @@
### key (optional)
Path to identity file used by `ssh -i`.
-
+
key /path/to/some.pem
### ref (optional)
@@ -63,33 +63,41 @@
utilize the most recent tag by default, however this is useful
for a staging environment, as shown below where __HEAD__ is updated
and set to the develop branch.
-
+
ref origin/develop
### user
User for deployment.
-
+
user deployer
### host
Server hostname.
-
+
host 50.17.255.50
### repo
GIT repository to clone.
-
+
repo git@github.com:visionmedia/express.git
### path
Deployment path.
-
+
path /var/www/myapp.com
+### forward-agent
+
+ Webhosts normally use read-only deploy keys to access private git repositories.
+ If you'd rather use the credentials of the person invoking the deploy
+ command, put `forward-agent yes` in the relevant config sections.
+ Now the deploy script will invoke `ssh -A` when deploying and there's
+ no need to keep SSH keys on your servers.
+
### Hooks
All hooks are arbitrary commands, executed relative to `path/current`,
@@ -112,7 +120,7 @@
test ./something
-## License
+## License
(The MIT License)
@@ -135,4 +143,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
30 bin/deploy
@@ -98,17 +98,25 @@ version() {
}
#
+# Return the ssh command to run.
+#
+
+ssh_command() {
+ local url="`config_get user`@`config_get host`"
+ local key="`config_get key`"
+ local forward_agent="`config_get forward-agent`"
+
+ test -n "$forward_agent" && local agent="-A"
+ test -n "$key" && local identity="-i $key"
+ echo "ssh $agent $identity $url"
+}
+
+#
# Run the given remote <cmd>.
#
run() {
- local url="`config_get user`@`config_get host`"
- local key=`config_get key`
- if test -n "$key"; then
- local shell="ssh -i $key $url"
- else
- local shell="ssh $url"
- fi
+ local shell="`ssh_command`"
echo $shell "\"$@\"" >> $LOG
$shell $@
}
@@ -118,13 +126,7 @@ run() {
#
console() {
- local url="`config_get user`@`config_get host`"
- local key=`config_get key`
- if test -n "$key"; then
- local shell="ssh -i $key $url"
- else
- local shell="ssh $url"
- fi
+ local shell="`ssh_command`"
echo $shell
exec $shell
}

0 comments on commit 510f7ab

Please sign in to comment.