Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
awit-ssh-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
allworldit
awit-ssh-client
Commits
732f2def
Commit
732f2def
authored
8 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added --rsync support
parent
fe3b0e2f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!15
Added rsync support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
awit-ssh
+96
-19
96 additions, 19 deletions
awit-ssh
with
96 additions
and
19 deletions
awit-ssh
+
96
−
19
View file @
732f2def
...
...
@@ -67,6 +67,8 @@ GetOptions(\%optctl,
"
debug
",
"
knock=s
",
"
rsync
",
)
or
exit
1
;
# Check for help
...
...
@@ -81,6 +83,13 @@ if (defined($optctl{'version'})) {
exit
0
;
}
# Check if we using rsync instead of SSH
my
$useRsync
=
0
;
my
@rsyncParams
;
if
(
defined
(
my
$rsyncHost
=
$optctl
{'
rsync
'}))
{
$useRsync
=
$rsyncHost
;
}
# Check if we should be doing port knocking
my
(
$knockHost
,
$knockPort
);
if
(
defined
(
my
$knock
=
$optctl
{'
knock
'}))
{
...
...
@@ -97,7 +106,33 @@ if (defined(my $knock = $optctl{'knock'})) {
my
$loginUsername
;
# Pull in hostname
my
$hostSpec
=
shift
(
@ARGV
)
//
"";
my
$hostSpec
;
if
(
$useRsync
)
{
foreach
my
$param
(
@ARGV
)
{
# Look for the remote:// param
if
(
$param
=~
/remote:\/\//
)
{
# Remove it and set the hostSpec
my
$removedTag
=
substr
(
$param
,
9
);
# Assing hostSpec to the first part of the tag
(
$hostSpec
)
=
split
(
/[\/:]/
,
$removedTag
);
# Change first / to a :/
$removedTag
=~
s,/,:/,
;
push
(
@rsyncParams
,
$removedTag
);
# Else just add it
}
else
{
push
(
@rsyncParams
,
$param
);
}
}
# Make sure we got a hostSpec
if
(
!
defined
(
$hostSpec
))
{
logger
('
ERROR
',
color
('
magenta
')
.
"
awit-ssh --rsync needs a remote://SERVER.... to be specified on the command line
"
.
color
('
reset
'));
exit
1
;
}
}
else
{
$hostSpec
=
shift
(
@ARGV
)
//
"";
}
my
(
$loginHost
,
$loginPort
)
=
split
('
:
',
$hostSpec
);
if
(
defined
(
$loginHost
))
{
# Suck in username if specified
...
...
@@ -524,16 +559,34 @@ if (defined($forwardSocket)) {
logger
('
NOTICE
',"
Connecting to host '
"
.
color
('
green
')
.
"
$forwardHost
"
.
color
('
reset
')
.
"
'
"
.
(
defined
(
$forwardPort
)
?
"
on port '
"
.
color
('
green
')
.
"
$forwardPort
"
.
color
('
reset
')
.
"
'
"
:
"")
.
"
...
\n\n\n
");
# Fire up ssh
system
('
/usr/bin/ssh
',
@sshArgs
,
# Override where we connecting to
'
-o
',"
ProxyCommand=nc -U
$forwardSocket
",
# Explicitly disable control master
'
-o
','
ControlMaster=no
',
$realLoginHost
);
# Check what operation we're doing
if
(
$useRsync
)
{
# Build SSH command
my
$sshCmd
=
join
('
','
/usr/bin/ssh
',
@sshArgs
,
# Override where we connecting to
'
-o
',"
ProxyCommand=
\"
nc -U
$forwardSocket
\"
",
# Explicitly disable control master
'
-o
','
ControlMaster=no
',
);
# Run rsync
system
('
/usr/bin/rsync
',
'
-e
',
$sshCmd
,
@rsyncParams
);
# Normal SSH
}
else
{
# Fire up SSH
system
('
/usr/bin/ssh
',
@sshArgs
,
# Override where we connecting to
'
-o
',"
ProxyCommand=nc -U
$forwardSocket
",
# Explicitly disable control master
'
-o
','
ControlMaster=no
',
$realLoginHost
);
}
# Unlink socket and unset it to designate we exited normally
unlink
(
$forwardSocket
);
...
...
@@ -564,13 +617,31 @@ if (defined($forwardSocket)) {
push
(
@sshArgs
,'
-p
',
$loginPort
);
}
system
('
/usr/bin/ssh
',
@sshArgs
,
# Use basic compression
'
-o
','
Compression=yes
',
'
-o
','
CompressionLevel=1
',
$loginHost
);
# Check what operation we're doing
if
(
$useRsync
)
{
# Build SSH command
my
$sshCmd
=
join
('
','
/usr/bin/ssh
',
@sshArgs
,
# Use basic compression
'
-o
','
Compression=yes
',
'
-o
','
CompressionLevel=1
'
);
# Run rsync
system
('
/usr/bin/rsync
',
'
-e
',
$sshCmd
,
@rsyncParams
);
# Normal SSH
}
else
{
system
('
/usr/bin/ssh
',
@sshArgs
,
# Use basic compression
'
-o
','
Compression=yes
',
'
-o
','
CompressionLevel=1
',
$loginHost
);
}
}
...
...
@@ -636,11 +707,17 @@ sub displayHelp
{
print
(
STDERR
<<
EOF
);
Usage:
$
0
<
options
>
[
USER
@
]
HOST
$
0
<
options
>
--
rsync
--
<
rsync
options
>
remote:
//
[
USER
@
]
HOST
/file.name /
tmp
General
Options:
--
help
What
you
'
re seeing now.
--version Display version.
--debug Enable debugging.
Secure Copy: (using rsync)
--rsync Run rsync instead of ssh, passing all
command line parameters after the host
to it. HOST is used for searching
LDAP.
Port Knocking:
--knock HOST:PORT Port knock a host to get access.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment