Using scp with a forwarded ssh agent

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I'm currently trying to scp a file from one server to another, using an ssh key on my local computer.



this is the command I'm currently using:



sudo scp -r -o "ForwardAgent yes" <new_folder> <second-server-path>


and I've followed this github doc to verify that my ssh agent is being forwarded to the second server's terminal.



-o "ForwardAgent yes" comes from this reference, but does not appear on my man scp reference.



However, after all this, the command still asks for a password (which we are trying to avoid). Any ideas on how to use the ssh forwarding?










share|improve this question























  • can you access via ssh to the second server without password ?
    – Wissam Roujoulah
    Nov 30 '16 at 14:12










  • I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
    – efong5
    Nov 30 '16 at 14:39










  • check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
    – Wissam Roujoulah
    Nov 30 '16 at 14:41














up vote
3
down vote

favorite












I'm currently trying to scp a file from one server to another, using an ssh key on my local computer.



this is the command I'm currently using:



sudo scp -r -o "ForwardAgent yes" <new_folder> <second-server-path>


and I've followed this github doc to verify that my ssh agent is being forwarded to the second server's terminal.



-o "ForwardAgent yes" comes from this reference, but does not appear on my man scp reference.



However, after all this, the command still asks for a password (which we are trying to avoid). Any ideas on how to use the ssh forwarding?










share|improve this question























  • can you access via ssh to the second server without password ?
    – Wissam Roujoulah
    Nov 30 '16 at 14:12










  • I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
    – efong5
    Nov 30 '16 at 14:39










  • check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
    – Wissam Roujoulah
    Nov 30 '16 at 14:41












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I'm currently trying to scp a file from one server to another, using an ssh key on my local computer.



this is the command I'm currently using:



sudo scp -r -o "ForwardAgent yes" <new_folder> <second-server-path>


and I've followed this github doc to verify that my ssh agent is being forwarded to the second server's terminal.



-o "ForwardAgent yes" comes from this reference, but does not appear on my man scp reference.



However, after all this, the command still asks for a password (which we are trying to avoid). Any ideas on how to use the ssh forwarding?










share|improve this question















I'm currently trying to scp a file from one server to another, using an ssh key on my local computer.



this is the command I'm currently using:



sudo scp -r -o "ForwardAgent yes" <new_folder> <second-server-path>


and I've followed this github doc to verify that my ssh agent is being forwarded to the second server's terminal.



-o "ForwardAgent yes" comes from this reference, but does not appear on my man scp reference.



However, after all this, the command still asks for a password (which we are trying to avoid). Any ideas on how to use the ssh forwarding?







linux ssh terminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 '16 at 16:24









Jakuje

15.8k52850




15.8k52850










asked Nov 30 '16 at 14:09









efong5

1814




1814











  • can you access via ssh to the second server without password ?
    – Wissam Roujoulah
    Nov 30 '16 at 14:12










  • I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
    – efong5
    Nov 30 '16 at 14:39










  • check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
    – Wissam Roujoulah
    Nov 30 '16 at 14:41
















  • can you access via ssh to the second server without password ?
    – Wissam Roujoulah
    Nov 30 '16 at 14:12










  • I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
    – efong5
    Nov 30 '16 at 14:39










  • check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
    – Wissam Roujoulah
    Nov 30 '16 at 14:41















can you access via ssh to the second server without password ?
– Wissam Roujoulah
Nov 30 '16 at 14:12




can you access via ssh to the second server without password ?
– Wissam Roujoulah
Nov 30 '16 at 14:12












I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
– efong5
Nov 30 '16 at 14:39




I can access the terminal of both servers from my own computer without a password. However, I am running into these issues between copying a file from one server to another @WissamAl-Roujoulah
– efong5
Nov 30 '16 at 14:39












check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
– Wissam Roujoulah
Nov 30 '16 at 14:41




check the user that you are trying to use on the remote server and make sure that is the same use that you added a ssh key for it when you copy the file
– Wissam Roujoulah
Nov 30 '16 at 14:41










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










  • scp does not support to forward your agent (hardcoded to be disabled in the code) so this is not possible what you are trying.



  • The problem is in sudo. Connection to ssh-agent is stored in environment variable SSH_AUTH_SOCK (echo $SSH_AUTH_SOCK) and this variable is not preserved during the sudo so there are two possibilities:



    • Do not use sudo to scp. Run just scp to some sane location and then sudo cp the file to the desired location.



    • Force sudo to preserve env. variables using the -E switch:



      sudo scp -r <new_folder> <second-server-path>



  • When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent.






share|improve this answer






















  • "When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
    – Sacha Vorbeck
    Sep 5 at 7:56











  • @SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
    – Jakuje
    Sep 5 at 18:10










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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f327085%2fusing-scp-with-a-forwarded-ssh-agent%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










  • scp does not support to forward your agent (hardcoded to be disabled in the code) so this is not possible what you are trying.



  • The problem is in sudo. Connection to ssh-agent is stored in environment variable SSH_AUTH_SOCK (echo $SSH_AUTH_SOCK) and this variable is not preserved during the sudo so there are two possibilities:



    • Do not use sudo to scp. Run just scp to some sane location and then sudo cp the file to the desired location.



    • Force sudo to preserve env. variables using the -E switch:



      sudo scp -r <new_folder> <second-server-path>



  • When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent.






share|improve this answer






















  • "When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
    – Sacha Vorbeck
    Sep 5 at 7:56











  • @SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
    – Jakuje
    Sep 5 at 18:10














up vote
3
down vote



accepted










  • scp does not support to forward your agent (hardcoded to be disabled in the code) so this is not possible what you are trying.



  • The problem is in sudo. Connection to ssh-agent is stored in environment variable SSH_AUTH_SOCK (echo $SSH_AUTH_SOCK) and this variable is not preserved during the sudo so there are two possibilities:



    • Do not use sudo to scp. Run just scp to some sane location and then sudo cp the file to the desired location.



    • Force sudo to preserve env. variables using the -E switch:



      sudo scp -r <new_folder> <second-server-path>



  • When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent.






share|improve this answer






















  • "When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
    – Sacha Vorbeck
    Sep 5 at 7:56











  • @SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
    – Jakuje
    Sep 5 at 18:10












up vote
3
down vote



accepted







up vote
3
down vote



accepted






  • scp does not support to forward your agent (hardcoded to be disabled in the code) so this is not possible what you are trying.



  • The problem is in sudo. Connection to ssh-agent is stored in environment variable SSH_AUTH_SOCK (echo $SSH_AUTH_SOCK) and this variable is not preserved during the sudo so there are two possibilities:



    • Do not use sudo to scp. Run just scp to some sane location and then sudo cp the file to the desired location.



    • Force sudo to preserve env. variables using the -E switch:



      sudo scp -r <new_folder> <second-server-path>



  • When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent.






share|improve this answer














  • scp does not support to forward your agent (hardcoded to be disabled in the code) so this is not possible what you are trying.



  • The problem is in sudo. Connection to ssh-agent is stored in environment variable SSH_AUTH_SOCK (echo $SSH_AUTH_SOCK) and this variable is not preserved during the sudo so there are two possibilities:



    • Do not use sudo to scp. Run just scp to some sane location and then sudo cp the file to the desired location.



    • Force sudo to preserve env. variables using the -E switch:



      sudo scp -r <new_folder> <second-server-path>



  • When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 30 '16 at 15:03

























answered Nov 30 '16 at 14:57









Jakuje

15.8k52850




15.8k52850











  • "When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
    – Sacha Vorbeck
    Sep 5 at 7:56











  • @SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
    – Jakuje
    Sep 5 at 18:10
















  • "When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
    – Sacha Vorbeck
    Sep 5 at 7:56











  • @SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
    – Jakuje
    Sep 5 at 18:10















"When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
– Sacha Vorbeck
Sep 5 at 7:56





"When you want to copy the file between two servers, use -3 switch, which will make both authentications from your host, where you have access to your agent." according to the man page, there is no -3 option. Only 1,2,4 or 6.
– Sacha Vorbeck
Sep 5 at 7:56













@SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
– Jakuje
Sep 5 at 18:10




@SachaVorbeck It probably means that you have very old OpenSSH version. Try to update.
– Jakuje
Sep 5 at 18:10

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f327085%2fusing-scp-with-a-forwarded-ssh-agent%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)