ssh login using a script
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 |
Quote:
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. |
Quote:
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:
|
Quote:
storing key is important prior |
Quote:
Code:
ssh-copy-id user@remotehost |
Thanks guys for your worthful advise and suggestions.
I have used ssh-keygen and ssh-copy-id remotehost into all my servers the script is working fine Hence marking it as solved |
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.
|
Quote:
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. |
Quote:
|
All times are GMT -5. The time now is 11:25 PM. |