Download/upload whole directories to/from remote environments using scp
, ssh
, and packing files with tar
in one command.
In common sense it's something similar to SFTP aliases.
It uses SSH for running commands (for pack/unpack files, etc.) and SCP for deploy/download target file/archive of files.
For packing files uses tar
.
The script can archive whole directory and transfer it. And it's much faster than transferring files with IDE like IDEA because it process them one-by-one.
At first, we need to download binary file
$ curl -Ls https://raw.github.com/rikby/sscp/master/download | bash
Now it should be ready to use.
$ sscp --help
$ sscp vars
# default name of config file
SSCP_RC=.sscprc
# directory where base .sscprc file (your home directory)
SSCP_BASE_DIR=/root
# SSH binary file
SSCP_SSH_BIN=ssh
# SCP binary file
SSCP_SCP_BIN=scp
# Default exclude list
SSCP_EXCLUDE=.idea
# Default connection
SSCP_CONNECT=vagrant@127.0.0.1
# Default temp directory. It uses in a remote server as well
SSCP_TEMP=~
# disable using colors
SSCP_NO_COLOR=0
# default verbose level (0- silent, 1- normal, 2- "very" mode, 3- debug)
SSCP_VERBOSE=1
You may print allowed environment variables:
$ sscp vars
(Example with vagrant connection.)
Initial ~/.sscprc
file with example of the connection to Vagrant VM.
connect='your-host'
But it will be more useful to add a SSH configuration:
$ cat ~/.ssh/config
Host your-host yh
HostName your-host
User vagrant
Port 2200
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile D:/vms/my-vm/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
And define your connection only:
connect='your-host'
$ sscp test
OK
See vagrant ssh-config
for vagrant.
Also you may add base paths:
remote_base_dir='/var/www'
local_base_dir='/d/home'
By default it has values:
connect='vagrant@127.0.0.1'
port=''
# Base directory for remote VM/server
remote_base_dir=''
# Base directory for for the current workstation
local_base_dir=''
# It will use port if exists
ssh_connect="ssh ${connect} -p ${port}"
scp_connect="scp -P ${port}"
To upload folder it has format
$ sscp upload LOCAL_PATH REMOTE_PATH [-p PORT]
To download folder it has format
$ sscp download REMOTE_PATH [LOCAL_PATH] [-p PORT]
To get expanded help please use command:
$ sscp --help