How to specify port for scp for a remote server?scp permission denied after 'hardening' with bastilleHow to...
Unbiased estimator of exponential of measure of a set?
Did Wernher von Braun really have a "Saturn V painted as the V2"?
Inset Square From a Rectangular Face
Number of matrices with bounded products of rows and columns
Graph of the function (2x^2-2)/(x^2-1)
How to shade a polygon with curved lines in tikz?
What is "super" in superphosphate?
Is there such a thing as too inconvenient?
Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?
Can others monetize my project with GPLv3?
What happened after the end of the Truman Show?
How to detect a failed AES256 decryption programmatically?
Do predators tend to have vertical slit pupils versus horizontal for prey animals?
My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?
Why Won't my Serial Read value stay the same
Playing a fast but quiet Alberti bass
Reducing contention in thread-safe LruCache
Would it be illegal for Facebook to actively promote a political agenda?
Are unaudited server logs admissible in a court of law?
Installing the original OS X version onto a Mac?
Why do balloons get cold when they deflate?
Independence of Mean and Variance of Discrete Uniform Distributions
Hiker's Cabin Mystery | Pt. XV
Earliest evidence of objects intended for future archaeologists?
How to specify port for scp for a remote server?
scp permission denied after 'hardening' with bastilleHow to copy files within a remote server?SCP from remote to local does not workscp does not honor .ssh/configIs there a BASH protection on remote copy of root files?scp through jump server with password, destination authenticated with private keyError copying directory from a remote host to another remote host with 'scp'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have two remote nodes that I am trying to send files from one to another.
scp remote1:~/testSCP remote2@10.0.1.10:~/
I have ~/ssh/config
set up in my local machine so, it is using port 2222
by default.
But the remote1's default ssh port is set to 22
in the ssh config instead of port 2222
. So, to make any external connection via ssh, it uses port 22
by default.
I tried the following which did not work:
scp -P 2222 remote1:~/testSCP remote2@10.0.1.10:~/
Also tried the following, which also did not work:
scp remote1:~/testSCP -P 2222 remote2@10.0.1.10:~/
For both I got the following error:
ssh: connect to host 10.0.1.10 port 22: Connection refused
lost connection
Which is true since 10.0.1.10
is using port 2222
and not port 22
.
How can I specify remote1 to use port 2222
when trying to send files to 10.0.1.10
(remote2) from remote1
?
Update
After trying
scp -3 remote1:~/testSCP remote2@10.0.1.10:~/
I get weird behaviour. Even though my password is correct, it is giving me the following output:
remote1@10.0.1.9's password: remote2@10.0.1.10's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
I have not enabled key-less authentication yet.
New Update
After trying it in several ways, I was able to do it in my scripts by logging in to the remote1 via ssh from my localhost and then scp from remote1 to remote2. However, this does not answer my question. I intended upon doing it directly from my local machine then transfer files between two instances, which I think is not supported if two instances' ssh daemons are using a different port than the default for ssh connection.
ssh scp remote
add a comment |
I have two remote nodes that I am trying to send files from one to another.
scp remote1:~/testSCP remote2@10.0.1.10:~/
I have ~/ssh/config
set up in my local machine so, it is using port 2222
by default.
But the remote1's default ssh port is set to 22
in the ssh config instead of port 2222
. So, to make any external connection via ssh, it uses port 22
by default.
I tried the following which did not work:
scp -P 2222 remote1:~/testSCP remote2@10.0.1.10:~/
Also tried the following, which also did not work:
scp remote1:~/testSCP -P 2222 remote2@10.0.1.10:~/
For both I got the following error:
ssh: connect to host 10.0.1.10 port 22: Connection refused
lost connection
Which is true since 10.0.1.10
is using port 2222
and not port 22
.
How can I specify remote1 to use port 2222
when trying to send files to 10.0.1.10
(remote2) from remote1
?
Update
After trying
scp -3 remote1:~/testSCP remote2@10.0.1.10:~/
I get weird behaviour. Even though my password is correct, it is giving me the following output:
remote1@10.0.1.9's password: remote2@10.0.1.10's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
I have not enabled key-less authentication yet.
New Update
After trying it in several ways, I was able to do it in my scripts by logging in to the remote1 via ssh from my localhost and then scp from remote1 to remote2. However, this does not answer my question. I intended upon doing it directly from my local machine then transfer files between two instances, which I think is not supported if two instances' ssh daemons are using a different port than the default for ssh connection.
ssh scp remote
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.
– Rakib Fiha
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your~/.ssh/config
files. Then, you mayssh
into one to the remote hosts and issue a simplescp
from there, or do it in one line with something asssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to editconfig
files any single time: only once for each couple of hosts (e.g. setting the port for connecting toremote2
onremote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.
– fra-san
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago
add a comment |
I have two remote nodes that I am trying to send files from one to another.
scp remote1:~/testSCP remote2@10.0.1.10:~/
I have ~/ssh/config
set up in my local machine so, it is using port 2222
by default.
But the remote1's default ssh port is set to 22
in the ssh config instead of port 2222
. So, to make any external connection via ssh, it uses port 22
by default.
I tried the following which did not work:
scp -P 2222 remote1:~/testSCP remote2@10.0.1.10:~/
Also tried the following, which also did not work:
scp remote1:~/testSCP -P 2222 remote2@10.0.1.10:~/
For both I got the following error:
ssh: connect to host 10.0.1.10 port 22: Connection refused
lost connection
Which is true since 10.0.1.10
is using port 2222
and not port 22
.
How can I specify remote1 to use port 2222
when trying to send files to 10.0.1.10
(remote2) from remote1
?
Update
After trying
scp -3 remote1:~/testSCP remote2@10.0.1.10:~/
I get weird behaviour. Even though my password is correct, it is giving me the following output:
remote1@10.0.1.9's password: remote2@10.0.1.10's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
I have not enabled key-less authentication yet.
New Update
After trying it in several ways, I was able to do it in my scripts by logging in to the remote1 via ssh from my localhost and then scp from remote1 to remote2. However, this does not answer my question. I intended upon doing it directly from my local machine then transfer files between two instances, which I think is not supported if two instances' ssh daemons are using a different port than the default for ssh connection.
ssh scp remote
I have two remote nodes that I am trying to send files from one to another.
scp remote1:~/testSCP remote2@10.0.1.10:~/
I have ~/ssh/config
set up in my local machine so, it is using port 2222
by default.
But the remote1's default ssh port is set to 22
in the ssh config instead of port 2222
. So, to make any external connection via ssh, it uses port 22
by default.
I tried the following which did not work:
scp -P 2222 remote1:~/testSCP remote2@10.0.1.10:~/
Also tried the following, which also did not work:
scp remote1:~/testSCP -P 2222 remote2@10.0.1.10:~/
For both I got the following error:
ssh: connect to host 10.0.1.10 port 22: Connection refused
lost connection
Which is true since 10.0.1.10
is using port 2222
and not port 22
.
How can I specify remote1 to use port 2222
when trying to send files to 10.0.1.10
(remote2) from remote1
?
Update
After trying
scp -3 remote1:~/testSCP remote2@10.0.1.10:~/
I get weird behaviour. Even though my password is correct, it is giving me the following output:
remote1@10.0.1.9's password: remote2@10.0.1.10's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
Permission denied, please try again.
remote1@10.0.1.9's password:
I have not enabled key-less authentication yet.
New Update
After trying it in several ways, I was able to do it in my scripts by logging in to the remote1 via ssh from my localhost and then scp from remote1 to remote2. However, this does not answer my question. I intended upon doing it directly from my local machine then transfer files between two instances, which I think is not supported if two instances' ssh daemons are using a different port than the default for ssh connection.
ssh scp remote
ssh scp remote
edited 2 days ago
Rakib Fiha
asked 2 days ago
Rakib FihaRakib Fiha
731 silver badge14 bronze badges
731 silver badge14 bronze badges
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.
– Rakib Fiha
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your~/.ssh/config
files. Then, you mayssh
into one to the remote hosts and issue a simplescp
from there, or do it in one line with something asssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to editconfig
files any single time: only once for each couple of hosts (e.g. setting the port for connecting toremote2
onremote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.
– fra-san
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago
add a comment |
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.
– Rakib Fiha
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your~/.ssh/config
files. Then, you mayssh
into one to the remote hosts and issue a simplescp
from there, or do it in one line with something asssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to editconfig
files any single time: only once for each couple of hosts (e.g. setting the port for connecting toremote2
onremote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.
– fra-san
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant
~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant
~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.– Rakib Fiha
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your
~/.ssh/config
files. Then, you may ssh
into one to the remote hosts and issue a simple scp
from there, or do it in one line with something as ssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to edit config
files any single time: only once for each couple of hosts (e.g. setting the port for connecting to remote2
on remote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.– fra-san
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your
~/.ssh/config
files. Then, you may ssh
into one to the remote hosts and issue a simple scp
from there, or do it in one line with something as ssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to edit config
files any single time: only once for each couple of hosts (e.g. setting the port for connecting to remote2
on remote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.– fra-san
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
You cannot do that with a simple remote-to-remote scp [1].
Instead of it, ssh to the 1st remote host and run scp with a port argument from there:
ssh -p 2222 ruser1@rhost1 scp -P 2222 /rpath/1 ruser2@rhost2:/rpath/2
If you want to do exactly what scp
is doing, you can also add the -n -x -oClearAllForwardings=yes
options to ssh
, though that's usually not needed.
[1]: newer versions of scp
support a uri spec (including a port) instead of host:path
, but only when using the -3
option ("pass through the local host").
So you could probably use
scp -3 -P 2222 ruser1@rhost1:/rpath/1 scp://ruser2@rhost2:2222//rpath/2
(notice that the /
after the host[:port]
is not part of the path -- scp://user@host/file
will refer to ./file
in the user
's home directory).
But copying through the localhost is both slower, and in my experience it will hide errors. For instance, this won't print any error message, despite not being able to create any /foo/bar/baz
file:
scp -3 localhost:.bashrc localhost:/foo/bar/baz
I did not get to any depth into this -- just avoided it ;-)
If someone is not convinced by all this, they can look at the source code:
void
toremote(char *targ, int argc, char **argv)
{
...
} else if (host) { /* standard remote to remote */
if (tport != -1 && tport != SSH_DEFAULT_PORT) {
/* This would require the remote support URIs */
fatal("target port not supported with two "
"remote hosts without the -3 option");
}
Notice that the tport
variable is only set by parsing a scp://
uri, and it simply doesn't exist in versions older than 7.6p1 (Oct 2017).
Could you explain what-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done usingrsync
instead.
– Rakib Fiha
2 days ago
-x
disables X11 forwarding and-oClear..
disables all tcp forwardings (in case any of them were forced via~/.ssh/config
or/etc/ssh/ssh_config
)
– mosvy
2 days ago
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535852%2fhow-to-specify-port-for-scp-for-a-remote-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You cannot do that with a simple remote-to-remote scp [1].
Instead of it, ssh to the 1st remote host and run scp with a port argument from there:
ssh -p 2222 ruser1@rhost1 scp -P 2222 /rpath/1 ruser2@rhost2:/rpath/2
If you want to do exactly what scp
is doing, you can also add the -n -x -oClearAllForwardings=yes
options to ssh
, though that's usually not needed.
[1]: newer versions of scp
support a uri spec (including a port) instead of host:path
, but only when using the -3
option ("pass through the local host").
So you could probably use
scp -3 -P 2222 ruser1@rhost1:/rpath/1 scp://ruser2@rhost2:2222//rpath/2
(notice that the /
after the host[:port]
is not part of the path -- scp://user@host/file
will refer to ./file
in the user
's home directory).
But copying through the localhost is both slower, and in my experience it will hide errors. For instance, this won't print any error message, despite not being able to create any /foo/bar/baz
file:
scp -3 localhost:.bashrc localhost:/foo/bar/baz
I did not get to any depth into this -- just avoided it ;-)
If someone is not convinced by all this, they can look at the source code:
void
toremote(char *targ, int argc, char **argv)
{
...
} else if (host) { /* standard remote to remote */
if (tport != -1 && tport != SSH_DEFAULT_PORT) {
/* This would require the remote support URIs */
fatal("target port not supported with two "
"remote hosts without the -3 option");
}
Notice that the tport
variable is only set by parsing a scp://
uri, and it simply doesn't exist in versions older than 7.6p1 (Oct 2017).
Could you explain what-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done usingrsync
instead.
– Rakib Fiha
2 days ago
-x
disables X11 forwarding and-oClear..
disables all tcp forwardings (in case any of them were forced via~/.ssh/config
or/etc/ssh/ssh_config
)
– mosvy
2 days ago
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
add a comment |
You cannot do that with a simple remote-to-remote scp [1].
Instead of it, ssh to the 1st remote host and run scp with a port argument from there:
ssh -p 2222 ruser1@rhost1 scp -P 2222 /rpath/1 ruser2@rhost2:/rpath/2
If you want to do exactly what scp
is doing, you can also add the -n -x -oClearAllForwardings=yes
options to ssh
, though that's usually not needed.
[1]: newer versions of scp
support a uri spec (including a port) instead of host:path
, but only when using the -3
option ("pass through the local host").
So you could probably use
scp -3 -P 2222 ruser1@rhost1:/rpath/1 scp://ruser2@rhost2:2222//rpath/2
(notice that the /
after the host[:port]
is not part of the path -- scp://user@host/file
will refer to ./file
in the user
's home directory).
But copying through the localhost is both slower, and in my experience it will hide errors. For instance, this won't print any error message, despite not being able to create any /foo/bar/baz
file:
scp -3 localhost:.bashrc localhost:/foo/bar/baz
I did not get to any depth into this -- just avoided it ;-)
If someone is not convinced by all this, they can look at the source code:
void
toremote(char *targ, int argc, char **argv)
{
...
} else if (host) { /* standard remote to remote */
if (tport != -1 && tport != SSH_DEFAULT_PORT) {
/* This would require the remote support URIs */
fatal("target port not supported with two "
"remote hosts without the -3 option");
}
Notice that the tport
variable is only set by parsing a scp://
uri, and it simply doesn't exist in versions older than 7.6p1 (Oct 2017).
Could you explain what-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done usingrsync
instead.
– Rakib Fiha
2 days ago
-x
disables X11 forwarding and-oClear..
disables all tcp forwardings (in case any of them were forced via~/.ssh/config
or/etc/ssh/ssh_config
)
– mosvy
2 days ago
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
add a comment |
You cannot do that with a simple remote-to-remote scp [1].
Instead of it, ssh to the 1st remote host and run scp with a port argument from there:
ssh -p 2222 ruser1@rhost1 scp -P 2222 /rpath/1 ruser2@rhost2:/rpath/2
If you want to do exactly what scp
is doing, you can also add the -n -x -oClearAllForwardings=yes
options to ssh
, though that's usually not needed.
[1]: newer versions of scp
support a uri spec (including a port) instead of host:path
, but only when using the -3
option ("pass through the local host").
So you could probably use
scp -3 -P 2222 ruser1@rhost1:/rpath/1 scp://ruser2@rhost2:2222//rpath/2
(notice that the /
after the host[:port]
is not part of the path -- scp://user@host/file
will refer to ./file
in the user
's home directory).
But copying through the localhost is both slower, and in my experience it will hide errors. For instance, this won't print any error message, despite not being able to create any /foo/bar/baz
file:
scp -3 localhost:.bashrc localhost:/foo/bar/baz
I did not get to any depth into this -- just avoided it ;-)
If someone is not convinced by all this, they can look at the source code:
void
toremote(char *targ, int argc, char **argv)
{
...
} else if (host) { /* standard remote to remote */
if (tport != -1 && tport != SSH_DEFAULT_PORT) {
/* This would require the remote support URIs */
fatal("target port not supported with two "
"remote hosts without the -3 option");
}
Notice that the tport
variable is only set by parsing a scp://
uri, and it simply doesn't exist in versions older than 7.6p1 (Oct 2017).
You cannot do that with a simple remote-to-remote scp [1].
Instead of it, ssh to the 1st remote host and run scp with a port argument from there:
ssh -p 2222 ruser1@rhost1 scp -P 2222 /rpath/1 ruser2@rhost2:/rpath/2
If you want to do exactly what scp
is doing, you can also add the -n -x -oClearAllForwardings=yes
options to ssh
, though that's usually not needed.
[1]: newer versions of scp
support a uri spec (including a port) instead of host:path
, but only when using the -3
option ("pass through the local host").
So you could probably use
scp -3 -P 2222 ruser1@rhost1:/rpath/1 scp://ruser2@rhost2:2222//rpath/2
(notice that the /
after the host[:port]
is not part of the path -- scp://user@host/file
will refer to ./file
in the user
's home directory).
But copying through the localhost is both slower, and in my experience it will hide errors. For instance, this won't print any error message, despite not being able to create any /foo/bar/baz
file:
scp -3 localhost:.bashrc localhost:/foo/bar/baz
I did not get to any depth into this -- just avoided it ;-)
If someone is not convinced by all this, they can look at the source code:
void
toremote(char *targ, int argc, char **argv)
{
...
} else if (host) { /* standard remote to remote */
if (tport != -1 && tport != SSH_DEFAULT_PORT) {
/* This would require the remote support URIs */
fatal("target port not supported with two "
"remote hosts without the -3 option");
}
Notice that the tport
variable is only set by parsing a scp://
uri, and it simply doesn't exist in versions older than 7.6p1 (Oct 2017).
edited 2 days ago
answered 2 days ago
mosvymosvy
15.9k2 gold badges19 silver badges51 bronze badges
15.9k2 gold badges19 silver badges51 bronze badges
Could you explain what-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done usingrsync
instead.
– Rakib Fiha
2 days ago
-x
disables X11 forwarding and-oClear..
disables all tcp forwardings (in case any of them were forced via~/.ssh/config
or/etc/ssh/ssh_config
)
– mosvy
2 days ago
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
add a comment |
Could you explain what-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done usingrsync
instead.
– Rakib Fiha
2 days ago
-x
disables X11 forwarding and-oClear..
disables all tcp forwardings (in case any of them were forced via~/.ssh/config
or/etc/ssh/ssh_config
)
– mosvy
2 days ago
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
Could you explain what
-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done using rsync
instead.– Rakib Fiha
2 days ago
Could you explain what
-x -oClearAllForwardings=yes
this option is doing in your answer please? I was also thinking if it can be done using rsync
instead.– Rakib Fiha
2 days ago
-x
disables X11 forwarding and -oClear..
disables all tcp forwardings (in case any of them were forced via ~/.ssh/config
or /etc/ssh/ssh_config
)– mosvy
2 days ago
-x
disables X11 forwarding and -oClear..
disables all tcp forwardings (in case any of them were forced via ~/.ssh/config
or /etc/ssh/ssh_config
)– mosvy
2 days ago
1
1
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
@RakibFiha rsync says: "The source and destination cannot both be remote". Maybe there are tricks around it, but that should be a separate question.
– mosvy
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
Now, I got to realise it after your detailed explanation. (y)
– Rakib Fiha
2 days ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535852%2fhow-to-specify-port-for-scp-for-a-remote-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/questions/10341032/… might help you
– Panki
2 days ago
I tried those as I mentioned in my question. Did not seem to work for me
– Rakib Fiha
2 days ago
localhost listening to port 22 but in ssh config its specefied for both remote1 to remote2 to port 2222. Yes, I meant
~/.ssh/config
In remote 1 and remote the default port in ~/.ssh/config is unchanged so its default port 22. I can edit them, but I would like to do it using a one-liner, instead of editing every ssh config every single time.– Rakib Fiha
2 days ago
Ok. I'd suggest to edit your question, adding that you can, but aren't willing to, edit your
~/.ssh/config
files. Then, you mayssh
into one to the remote hosts and issue a simplescp
from there, or do it in one line with something asssh -t -p <remote1 port> user1@remote1 'scp -P <remote2 port> user2@remote2:/source/path /dest/path'
. Also, you won't have to editconfig
files any single time: only once for each couple of hosts (e.g. setting the port for connecting toremote2
onremote1
), but of course you may be uncomfortable with this, depending on the number of hosts you have.– fra-san
2 days ago
Yes, that does answer your question. "No" is an answer and is the answer, no matter if you like it or not.
– mosvy
2 days ago