How to use scp in a bash script without specifying password?File encryption in a bash script without...
How does a predictive coding aid in lossless compression?
Expand and Contract
How can I determine if the org that I'm currently connected to is a scratch org?
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
How to tell a function to use the default argument values?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
Ambiguity in the definition of entropy
Should I cover my bicycle overnight while bikepacking?
Is it possible to create a QR code using text?
How do I gain back my faith in my PhD degree?
Arrow those variables!
Intersection Puzzle
I would say: "You are another teacher", but she is a woman and I am a man
Reverse dictionary where values are lists
Why would the Red Woman birth a shadow if she worshipped the Lord of the Light?
How seriously should I take size and weight limits of hand luggage?
A category-like structure without composition?
iPad being using in wall mount battery swollen
Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?
Plagiarism or not?
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
Can we compute the area of a quadrilateral with one right angle when we only know the lengths of any three sides?
Do UK voters know if their MP will be the Speaker of the House?
How to use scp in a bash script without specifying password?
File encryption in a bash script without explicity providing passwordRunning bash script that uses ssh and scp (prompts for password) securelyUpload file with SCP bash scriptaescrypt doesn't function with pv in pipelineHow to execute bash script without password?ssh without password from a bash scriptHow to scp without password prompt without storing private keyHow to scp-and-ssh with specifying host twice?SCP Hidden Password Promptrun ssh / scp from bash script w/out password - key installed
I am a bash newbie, and am writing a bash script that will allow transfer of files between two computers. BTW, is there a more secure alternative to scp?
Currently, I am doing this manually, by using scp. The remote server always prompts me for the password, and I supply that. I want to automate this (hence the bash script). However, I dont want to supply my password in plain text (or if at all - I was under the impression that open SSL does away with passwords and uses certificates etc?).
Can anyone please explain how I can automate my current process, without explicitly displaying my password.
I am running on Ubuntu 10.0.4
linux ubuntu bash scp
add a comment |
I am a bash newbie, and am writing a bash script that will allow transfer of files between two computers. BTW, is there a more secure alternative to scp?
Currently, I am doing this manually, by using scp. The remote server always prompts me for the password, and I supply that. I want to automate this (hence the bash script). However, I dont want to supply my password in plain text (or if at all - I was under the impression that open SSL does away with passwords and uses certificates etc?).
Can anyone please explain how I can automate my current process, without explicitly displaying my password.
I am running on Ubuntu 10.0.4
linux ubuntu bash scp
add a comment |
I am a bash newbie, and am writing a bash script that will allow transfer of files between two computers. BTW, is there a more secure alternative to scp?
Currently, I am doing this manually, by using scp. The remote server always prompts me for the password, and I supply that. I want to automate this (hence the bash script). However, I dont want to supply my password in plain text (or if at all - I was under the impression that open SSL does away with passwords and uses certificates etc?).
Can anyone please explain how I can automate my current process, without explicitly displaying my password.
I am running on Ubuntu 10.0.4
linux ubuntu bash scp
I am a bash newbie, and am writing a bash script that will allow transfer of files between two computers. BTW, is there a more secure alternative to scp?
Currently, I am doing this manually, by using scp. The remote server always prompts me for the password, and I supply that. I want to automate this (hence the bash script). However, I dont want to supply my password in plain text (or if at all - I was under the impression that open SSL does away with passwords and uses certificates etc?).
Can anyone please explain how I can automate my current process, without explicitly displaying my password.
I am running on Ubuntu 10.0.4
linux ubuntu bash scp
linux ubuntu bash scp
asked Jul 30 '10 at 9:55
morpheousmorpheous
1,63892628
1,63892628
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
To login without password you need to setup key-based authentication. There are a number of tutorials out there - this one looks like a good place to start (edit: the original site fell of the Internet, this link is to the last copy archived by the WayBackMachine).
If you put a passphrase on your key (recommended) you will still need to provide that when you login but you can use ssh-agent to reduce the amount of times you have to provide it.
If you need scripts that use SSH/SCP to run unattended then you need to not have a passphrase on your key, but in this case you absolutely must keep that key file secure such that no-one else can read it otherwise they will be able to authenticate on that server as you without any password/passphrase.
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
add a comment |
supply a password to scp
Piping your password to the standard input of scp won't work:
echo "password" | scp file user@host:/dir/to/copy/to
because scp doesn't read from the standard input for security reasons.
Use the tool sshpass instead:
You may have to install sshpass as root since it is non standard.
sshpass -p 'mypassword' scp -r el@myserv.com:/home/a/moo.txt /home/b/bar.txt
add a comment |
If you use a key like .pem etc (so you wouldn't have to have a password) you could use this
here's bash code for SCP with a .pem key file.
Just save it to a script.sh file then run with 'sh script.sh'
Enjoy
#!/bin/bash
#Error function
function die(){
echo "$1"
exit 1
}
Host=ec2-53-298-45-63.us-west-1.compute.amazonaws.com
User=ubuntu
#Directory at sent destination
SendDirectory=scp
#File to send at host
FileName=filetosend.txt
#Key file
Key=MyKeyFile.pem
echo "Aperture in Process...";
scp -i $Key $FileName $User@$Host:$SendDirectory ||
die "@@@@@@@Houston we have problem"
echo "########Aperture Complete#########";
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f169808%2fhow-to-use-scp-in-a-bash-script-without-specifying-password%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
To login without password you need to setup key-based authentication. There are a number of tutorials out there - this one looks like a good place to start (edit: the original site fell of the Internet, this link is to the last copy archived by the WayBackMachine).
If you put a passphrase on your key (recommended) you will still need to provide that when you login but you can use ssh-agent to reduce the amount of times you have to provide it.
If you need scripts that use SSH/SCP to run unattended then you need to not have a passphrase on your key, but in this case you absolutely must keep that key file secure such that no-one else can read it otherwise they will be able to authenticate on that server as you without any password/passphrase.
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
add a comment |
To login without password you need to setup key-based authentication. There are a number of tutorials out there - this one looks like a good place to start (edit: the original site fell of the Internet, this link is to the last copy archived by the WayBackMachine).
If you put a passphrase on your key (recommended) you will still need to provide that when you login but you can use ssh-agent to reduce the amount of times you have to provide it.
If you need scripts that use SSH/SCP to run unattended then you need to not have a passphrase on your key, but in this case you absolutely must keep that key file secure such that no-one else can read it otherwise they will be able to authenticate on that server as you without any password/passphrase.
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
add a comment |
To login without password you need to setup key-based authentication. There are a number of tutorials out there - this one looks like a good place to start (edit: the original site fell of the Internet, this link is to the last copy archived by the WayBackMachine).
If you put a passphrase on your key (recommended) you will still need to provide that when you login but you can use ssh-agent to reduce the amount of times you have to provide it.
If you need scripts that use SSH/SCP to run unattended then you need to not have a passphrase on your key, but in this case you absolutely must keep that key file secure such that no-one else can read it otherwise they will be able to authenticate on that server as you without any password/passphrase.
To login without password you need to setup key-based authentication. There are a number of tutorials out there - this one looks like a good place to start (edit: the original site fell of the Internet, this link is to the last copy archived by the WayBackMachine).
If you put a passphrase on your key (recommended) you will still need to provide that when you login but you can use ssh-agent to reduce the amount of times you have to provide it.
If you need scripts that use SSH/SCP to run unattended then you need to not have a passphrase on your key, but in this case you absolutely must keep that key file secure such that no-one else can read it otherwise they will be able to authenticate on that server as you without any password/passphrase.
edited Mar 29 '11 at 15:44
answered Jul 30 '10 at 10:14
David SpillettDavid Spillett
21.9k4062
21.9k4062
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
add a comment |
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
1
1
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
...and it's dead - was it hostingrails.com/HowTo-SSH-SCP-without-a-password or is there a better page?
– Stephen
Mar 29 '11 at 1:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
I've updated the link to point to a copy archived by the WayBackMachine.
– David Spillett
Mar 29 '11 at 15:44
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
was going to ask just this question as I am being prompted for passphrase :D will have to setup keys without passphrase now.
– TheVillageIdiot
Jun 8 '11 at 17:01
add a comment |
supply a password to scp
Piping your password to the standard input of scp won't work:
echo "password" | scp file user@host:/dir/to/copy/to
because scp doesn't read from the standard input for security reasons.
Use the tool sshpass instead:
You may have to install sshpass as root since it is non standard.
sshpass -p 'mypassword' scp -r el@myserv.com:/home/a/moo.txt /home/b/bar.txt
add a comment |
supply a password to scp
Piping your password to the standard input of scp won't work:
echo "password" | scp file user@host:/dir/to/copy/to
because scp doesn't read from the standard input for security reasons.
Use the tool sshpass instead:
You may have to install sshpass as root since it is non standard.
sshpass -p 'mypassword' scp -r el@myserv.com:/home/a/moo.txt /home/b/bar.txt
add a comment |
supply a password to scp
Piping your password to the standard input of scp won't work:
echo "password" | scp file user@host:/dir/to/copy/to
because scp doesn't read from the standard input for security reasons.
Use the tool sshpass instead:
You may have to install sshpass as root since it is non standard.
sshpass -p 'mypassword' scp -r el@myserv.com:/home/a/moo.txt /home/b/bar.txt
supply a password to scp
Piping your password to the standard input of scp won't work:
echo "password" | scp file user@host:/dir/to/copy/to
because scp doesn't read from the standard input for security reasons.
Use the tool sshpass instead:
You may have to install sshpass as root since it is non standard.
sshpass -p 'mypassword' scp -r el@myserv.com:/home/a/moo.txt /home/b/bar.txt
answered Dec 12 '12 at 4:28
Eric LeschinskiEric Leschinski
4,30343646
4,30343646
add a comment |
add a comment |
If you use a key like .pem etc (so you wouldn't have to have a password) you could use this
here's bash code for SCP with a .pem key file.
Just save it to a script.sh file then run with 'sh script.sh'
Enjoy
#!/bin/bash
#Error function
function die(){
echo "$1"
exit 1
}
Host=ec2-53-298-45-63.us-west-1.compute.amazonaws.com
User=ubuntu
#Directory at sent destination
SendDirectory=scp
#File to send at host
FileName=filetosend.txt
#Key file
Key=MyKeyFile.pem
echo "Aperture in Process...";
scp -i $Key $FileName $User@$Host:$SendDirectory ||
die "@@@@@@@Houston we have problem"
echo "########Aperture Complete#########";
New contributor
add a comment |
If you use a key like .pem etc (so you wouldn't have to have a password) you could use this
here's bash code for SCP with a .pem key file.
Just save it to a script.sh file then run with 'sh script.sh'
Enjoy
#!/bin/bash
#Error function
function die(){
echo "$1"
exit 1
}
Host=ec2-53-298-45-63.us-west-1.compute.amazonaws.com
User=ubuntu
#Directory at sent destination
SendDirectory=scp
#File to send at host
FileName=filetosend.txt
#Key file
Key=MyKeyFile.pem
echo "Aperture in Process...";
scp -i $Key $FileName $User@$Host:$SendDirectory ||
die "@@@@@@@Houston we have problem"
echo "########Aperture Complete#########";
New contributor
add a comment |
If you use a key like .pem etc (so you wouldn't have to have a password) you could use this
here's bash code for SCP with a .pem key file.
Just save it to a script.sh file then run with 'sh script.sh'
Enjoy
#!/bin/bash
#Error function
function die(){
echo "$1"
exit 1
}
Host=ec2-53-298-45-63.us-west-1.compute.amazonaws.com
User=ubuntu
#Directory at sent destination
SendDirectory=scp
#File to send at host
FileName=filetosend.txt
#Key file
Key=MyKeyFile.pem
echo "Aperture in Process...";
scp -i $Key $FileName $User@$Host:$SendDirectory ||
die "@@@@@@@Houston we have problem"
echo "########Aperture Complete#########";
New contributor
If you use a key like .pem etc (so you wouldn't have to have a password) you could use this
here's bash code for SCP with a .pem key file.
Just save it to a script.sh file then run with 'sh script.sh'
Enjoy
#!/bin/bash
#Error function
function die(){
echo "$1"
exit 1
}
Host=ec2-53-298-45-63.us-west-1.compute.amazonaws.com
User=ubuntu
#Directory at sent destination
SendDirectory=scp
#File to send at host
FileName=filetosend.txt
#Key file
Key=MyKeyFile.pem
echo "Aperture in Process...";
scp -i $Key $FileName $User@$Host:$SendDirectory ||
die "@@@@@@@Houston we have problem"
echo "########Aperture Complete#########";
New contributor
New contributor
answered 3 mins ago
Chief_ArbiterChief_Arbiter
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f169808%2fhow-to-use-scp-in-a-bash-script-without-specifying-password%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