ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi All,
I am trying to run the below command in a bash script.
ssh -t username0@hostname < a.txt ls >> ./$now.txt
where a.txt contains the password in plain text
I was getting below error:
Pseudo-terminal will not be allocated because stdin is not a terminal. error
after a bit of googling I have added -t still it is asking for password.
Hi All,
I am trying to run the below command in a bash script.
ssh -t username0@hostname < a.txt ls >> ./$now.txt
where a.txt contains the password in plain text
I was getting below error:
Pseudo-terminal will not be allocated because stdin is not a terminal. error
after a bit of googling I have added -t still it is asking for password.
Read the man page on SSH, and pay particular attention to the "SSH_ASKPASS" environment variable. And is that your entire 'script'?? Also, I bolded a line...are you seriously putting a password in a clear-text file for SSH? Why on earth would you do that???
A far better way to go would be to do a keyswap between the two systems, and just be able to run "ssh user@host", and have it function properly, with decent security.
Thanks TNOne for the quick reply
will check on "SSH_ASKPASS" thanks for the hint.
thats not all on the script there were more things though I was stuck on this.
A far better way to go would be to do a keyswap between the two systems, and just be able to run "ssh user@host", and have it function properly, with decent security.
I'll comment too since this method cannot be emphasized enough.
gsr_kashyap, take a look at how to use key-based authentication. You choice at the moment is really either RSA or Ed25519 algorithms for the key pair. The steps, minus some details, are:
generate the key pair using either algorithm, pay attention to the options -f and -C in the helper application ssh-keygen
copy the public key to the remote machine you will log in to
keep the private key on the client machine you will log in from
look at the -i option for the SSH client
look closely at the manual pages for the helper applications ssh-agent and ssh-add, they will allow you to automate your activities while still keeping a strong passphrase on the private key
Last edited by Turbocapitalist; 05-25-2017 at 11:44 PM.
Hi All,
I am trying to run the below command in a bash script.
ssh -t username0@hostname < a.txt ls >> ./$now.txt
where a.txt contains the password in plain text
I was getting below error:
Pseudo-terminal will not be allocated because stdin is not a terminal. error
after a bit of googling I have added -t still it is asking for password.
Need help in resolving this.
Thanks in advance
there are several website to store the key + password into the config of ssh.
storing key is important prior
Thanks TNOne for the quick reply
will check on "SSH_ASKPASS" thanks for the hint.
thats not all on the script there were more things though I was stuck on this.
So then post your entire script if you'd like help. Hard to offer any good advice based on a single line, without knowing the context or your actual goal. Storing a password ANYWHERE (in a script, a file called by a script, etc.), is just a horrible thing to do. And in this day and age, totally pointless, ESPECIALLY since you're using SSH. There is even a command called ssh-copy-id which works like this:
Code:
ssh-copy-id user@remotehost
That's it. If you're logged in as the user you want to have passwordless access, that's all you have to do. It'll prompt you for a password once, and never again. You store no passwords anywhere, and things are secure.
You can hardcode the password in, but it much safer to setup keys to allow ssh to connect to that machine/username without a password. Then it only works with that one machine/username, no one can grab your password and use it from anywhere.
You can hardcode the password in, but it much safer to setup keys to allow ssh to connect to that machine/username without a password. Then it only works with that one machine/username, no one can grab your password and use it from anywhere.
I have a additional questions regarding SSH keys:
If you connect with SSH keys and run commands which require sudo privileges, how do you do this? With a password, you would run the sudo command and enter a pwd for more privileges, but how to do this in a script?
please open a new thread, do not hide earlier issues. As you see noone interested, because this thread is actually closed.
Also you may click on REPORT and asks moderators to help you to.
please open a new thread, do not hide earlier issues. As you see noone interested, because this thread is actually closed.
Also you may click on REPORT and asks moderators to help you to.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.