aboutsummaryrefslogtreecommitdiff
path: root/scp.sh
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-05-21 05:26:34 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2019-05-21 05:26:34 +0200
commitff5b407fb4337aaea80da92cce9a526c52ccff10 (patch)
tree12b43c7e4f5550891935a7e11858fd523426ba87 /scp.sh
parent1c080783990429918a4b7fa4d383b36bf63fae1f (diff)
downloadscripts-ff5b407fb4337aaea80da92cce9a526c52ccff10.tar.gz
scripts-ff5b407fb4337aaea80da92cce9a526c52ccff10.zip
Created scripts for using ssh and scp with common hosts.
Diffstat (limited to 'scp.sh')
-rwxr-xr-xscp.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/scp.sh b/scp.sh
new file mode 100755
index 0000000..b01721f
--- /dev/null
+++ b/scp.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Allows to select a host to send files to through scp
+
+hostsfile="$HOME/.hosts"
+hostnames="$(cut -d'#' -f1 < "$hostsfile" | fzf)"
+host="$(grep "$hostnames" < "$hostsfile")"
+hostname="$(echo "$host" | cut -d'#' -f1)"
+hostaddress="$(echo "$host" | cut -d'#' -f2)"
+hostport="$(echo "$host" | cut -d'#' -f3)"
+hostpass="$(echo "$host" | cut -d'#' -f4)"
+targetPath="$(echo "$host" | cut -d'#' -f5)"
+echo "Sending to $hostname"
+[ "$hostpass" ] && pass -c "$hostpass"
+[ "$hostport" ] && scp -P $hostport "$@" $hostaddress:$targetPath || scp "$@" $hostaddress:$targetPath # No quotes here!