SSH password from file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SSH password from file
# 1  
Old 04-02-2014
Lightbulb SSH password from file

Hi Admin

I'm trying to execute on a script which in my production server. The production server has to phase login.

First, we need to login to a Taxi server by opening a putty session from there we need to login to production server. Both servers using same LDAP id so I am able to login with same user id.

Currently I am login with public key so that while doing SSH it won't ask for password.

I'm trying to SSH from Taxi to production servers, using user name and password from one text file. But I'm unable to get an idea how i can perform that.

Could you please help me in doing SSH and taking user name and password from a text file....? Is it possible to do so?

Current script i am using which works fine with my ID.

Code:
#!/bin/ksh
SSH_OPTS="-o ConnectTimeout=15 -o BatchMode=yes -o StrictHostKeyChecking=no -o LogLevel=quiet"
echo "$1"  | tr '|' '\n' | while read box
do
  ssh $SSH_OPTS -n $box -l $2 'ksh /home/user/cert.ksh "$2"' >> OUT.log
done

# 2  
Old 04-03-2014
You can use expect command to login to the server
Code:
VAR=$(expect -c 2> /dev/null "
    spawn ssh -n -T -o StrictHostKeyChecking=no $user@$host
    expect \"*?assword:*\"
    send -- \"$passwd\r\"
    send -- \"\r\"
    expect eof
    ")

here user is the user id
host is ip address
and passwd is password...

Please let me know if u need any other help..
This User Gave Thanks to temp_user For This Post:
# 3  
Old 04-03-2014
The reason why providing passwords to ssh (and similar commands, like passwd) is difficult ist, that - for security reasons - such programs clear <stdin>. A simple redirection program < /some/file or something to that effect will fail therefore.

Using expect or similar tools is possible, but the best solution is to stick with the key provided by the keyfile. Everything else is less secure and more error prone. It will always mean to store the password in a file and at some point of the execution to decrypt it (if it ever was encrypted in first place). If such a process provides enough security for you one has to wonder what you need passwords at all for.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 4  
Old 04-03-2014
Quote:
Originally Posted by senthil.ak
Currently I am login with public key so that while doing SSH it won't ask for password.
This is the recommended method, yes. What's wrong with it?
# 5  
Old 04-06-2014
@temp_user

How to use this, could you please explain how to include this in the script.
Is it
Code:
expect \"*?assword:*\"

correct one?

@bakunin

Yes i am using the openssl, so i guess its secured
Code:
passwd=`echo $passwd | openssl enc -base64 -d`


@Corona688
I have an external WEB program through which i am executing a script in a directory which runs and extract the details for the user and display in their screen. To login to the server I want to use the user password and login name so from web they pass that to server and we will save in a file and encrypt and use it for login.
# 6  
Old 04-06-2014
Quote:
Originally Posted by senthil.ak
Yes i am using the openssl, so i guess its secured
Code:
passwd=`echo $passwd | openssl enc -base64 -d`

encoding a string in base64 does not make it secured. base64 is not encryption. use SSH keys and make sure you check all return codes.
# 7  
Old 04-06-2014
Quote:
Originally Posted by senthil.ak
Yes i am using the openssl, so i guess its secured
Code:
passwd=`echo $passwd | openssl enc -base64 -d`


That is as "secured" as storing the password in clear text. In your command you use the openssl utility only as an encoding tool.

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh password

Hi there. I am fully aware of the security implications, but is there a way give a user password with the rsh and/or ssh commands? Such as: ssh user@192.168.0.56 -p password Or pass a config file to the command containing a password? I'm looking after a cluster and trying to use PSSH,... (6 Replies)
Discussion started by: MuntyScrunt
6 Replies

2. Red Hat

SSH password less setup asking for password

Hello Experts, when I am trying to connect my target server through sftp after creating ssh password less setup, it is asking for passowrd to connect. to setup this I followed below process: -->generated keys by executing the command "ssh-keygen -t rsa" -->this created my .ssh directory... (9 Replies)
Discussion started by: Devipriya Ch
9 Replies

3. Shell Programming and Scripting

Ssh to 100s of hosts with password in a shell script or text file

I have about 500 hosts where I need to ssh by sending the password on the command line or in a text file in a clear text . However I am not able to download "sshpass" or other tools . Any other ways to pass the password in a script ? (3 Replies)
Discussion started by: gubbu
3 Replies

4. Red Hat

ssh without password

Hi, I am trying to generate ssh without having to type a password. I have done this on numerous occasions using the procedure below and it has worked fine but not on this occasion. user1@sys1:ssh-keygen -t dsa -N "" <press enter for any questions> user1@sys1: ll .ssh/id_dsa.pub... (16 Replies)
Discussion started by: Duffs22
16 Replies

5. UNIX for Dummies Questions & Answers

SSH with no password

How to setup SSH to not require a password when establishing an SSH connection from server A to server B for particular user? (4 Replies)
Discussion started by: sam101
4 Replies

6. AIX

While trying to do ssh without password, rsa key file is created as empty.

Hi i have aix 5.3 operating system, and i am trying to do ssh without passwd, when i tried to create a rsakey, it produces empty file as an output, how can solve that problem? why it is giving empty output file, i tried with different user, situation same,.i have restarted sshd server. .ssh... (2 Replies)
Discussion started by: nibiru78
2 Replies

7. Shell Programming and Scripting

SSH with password

Please help me I want connect to orther server using ssh. But I need to transfer password also without entering when it is prompts. Please help me. (1 Reply)
Discussion started by: saga499
1 Replies

8. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

9. AIX

How to use SSH Secure File Transfer tool from windows to AIX without password?

If I use SSh Secure File Transfer tool on Windows, I want to transfer file from windows to AIX without password, how to do it? (6 Replies)
Discussion started by: rainbow_bean
6 Replies

10. UNIX for Dummies Questions & Answers

no password ssh

Hello all, I would like to know if anyone had ever set up a network in which they used DHCP and OPENSSH with no password. I can configure my ssh files to allow me to enter any machine without a password as long as I have generated the public and private keysa nd store them in my .ssh/aut... ... (3 Replies)
Discussion started by: larryase
3 Replies
Login or Register to Ask a Question