Operating System - HP-UX
1821980 Members
3445 Online
109638 Solutions
New Discussion юеВ

SFTP without applying password in script

 
Arunananth
Occasional Advisor

SFTP without applying password in script

How to sftp from ssh server to client server?
How to create sftp?
How to automate in script for sftp without password?

If i create script to pull the file means its asking password.

I have installed HPUX secure shell in both servers.

T1471AA A.05.10.006 HP-UX Secure Shell

Please help and suggest me how to proceed further.
19 REPLIES 19
Court Campbell
Honored Contributor

Re: SFTP without applying password in script

learn about ssh-keygen. And you have HP secure shell (openssh), so you have sftp.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

Yes, after installing in secure shell in ssh server i have sftp. but its getting timed out.

Please find the below output:

ssh01# sftp client01
Connecting to client01...
ssh: connect to host client01 port 22: Connection timed out
Connection closed

and

but when i connect in client server to ssh server it got connected.

client01# sftp ssh01
Connecting to ssh01...
Password:
sftp>



here ssh01 -> ssh server
client01 -> client server

please suggest me
Patrick Wallek
Honored Contributor

Re: SFTP without applying password in script

Are you sure the SSH daemon is running on the client01 machine?

It appears from the message that SSH may be installed, but the sshd daemon is not running.
Court Campbell
Honored Contributor

Re: SFTP without applying password in script

What OS is on client01?
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Steven Schweda
Honored Contributor

Re: SFTP without applying password in script

> It appears from the message that SSH may be
> installed, but the sshd daemon is not
> running.

Not to me. If sshd were not running (or
configured to run), I'd expect a "Connection
refused" complaint, not "Connection timed
out". I'd look for a firewall which might be
blocking the SSH traffic in one direction.

Is SSH the only service which fails this way?
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

Client server:

client01# uname -a
HP-UX client01 B.11.11 U 9000/800 104424606 unlimited-user license
client01# model
9000/800/L3000-5x

client01# ps -ef| grep -i sshd
root 8019 7843 1 07:46:02 pts/0 0:00 grep -i sshd
root 16714 1 0 Mar 10 ? 0:19 /opt/ssh/sbin/sshd


ssh server:

ssh01# uname -a
HP-UX ssh01 B.11.11 U 9000/800 355204990 unlimited-user license
ssh01# model
9000/800/rp3440

ssh01# ps -ef| grep -i sshd
root 2505 1 0 13:20:32 ? 0:06 /opt/ssh/sbin/sshd
root 11791 11553 0 07:41:40 pts/0 0:00 grep -i sshd
root 11540 2505 0 07:25:28 ? 0:00 sshd: aiyadura [priv]
aiyadura 11543 11540 0 07:25:35 ? 0:00 sshd: aiyadura@pts/0
T G Manikandan
Honored Contributor

Re: SFTP without applying password in script

Instead of sftp you can use scp to transfer files between the two systems

scp /tmp/a.txt aruna@targetmachine:/tmp

if you are looking to transfer files without a password check

http://saikrishbe.wordpress.com/2007/01/19/remote-login-without-password/
Ganesan R
Honored Contributor

Re: SFTP without applying password in script

Hi Arunanath,

If sshd daemon is running on client01, then you should be able to sftp.

Just restart the sshd daemon on client01 and try from ssh01.

#/sbin/init.d/secsh stop
#/sbin/init.d/secsh start

After restarting sshd, try this on client01 to confirm ssh port 22 is listening

client01#telnet localhost 22
client01#ssh localhost 22

If this works then you should be able to sftp to the server.

Creating a script to pull the files without password is next task which can be easily done by configuring passwordless login.

First fix the sftp issue.

Best wishes,

Ganesh.
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

When i try scp also in ssh server to client server also its not working,

ssh01# scp /tmp/test client01:/tmp/
ssh: connect to host client01 port 22: Connection timed out
lost connection
T G Manikandan
Honored Contributor

Re: SFTP without applying password in script

Might be some firewall is blocking the connection, check /etc/hosts.allow
Ganesan R
Honored Contributor

Re: SFTP without applying password in script

Hi Arunannth,

Is there any firewall in between ssh01 and client01? I strongly suspect there is afirewall which is blocking the connection from ssh01 to client01.

In that case you need to open the firwall port 22 for ssh01 to client01.

You check with your network team.
Best wishes,

Ganesh.
rariasn
Honored Contributor

Re: SFTP without applying password in script

He,

node1 and node2:

#grep -i sftp /etc/opt/ssh/sshd_config

Subsystem sftp /opt/ssh/libexec/sftp-server -f LOCAL1 -l INFO

node1#

sftp mode2<< EOF
pwd
quit
EOF

Connecting to node2...
sftp> pwd
Remote working directory: /root
sftp> quit

No password "prompt".
rgs,
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

Hi Ganesh,

As per your information i have tried the below following.

1. restarted sshd in client01

cd /sbin/init.d/secsh stop and start

2. in ssh01 i have tried

ssh01# sftp client01
Connecting to client01...
ssh: connect to host client01 port 22: Connection timed out
Connection closed

3. in client01


client01# telnet localhost 22
Trying...
Connected to localhost.armstrong.com.
Escape character is '^]'.
SSH-1.99-OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5
Connection closed by foreign host.


client01#ssh localhost 22
Password:
sh: 22: not found.

Please suggest me

Court Campbell
Honored Contributor

Re: SFTP without applying password in script

You would just ssh to localhost

ssh localhost

ssh localhost 22 will try to run the command 22. But being that it returned the error that 22 is not found, I would say that it is working locally.

You might try installing nmap on the machine to see if there is a firewall blocking the port. At this point I would assume there is.

http://hpux.connect.org.uk/hppd/hpux/Networking/Admin/nmap-4.76/

NOTE: you are more that likely going to need to install the dependencies for nmap.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Ganesan R
Honored Contributor

Re: SFTP without applying password in script

Hi Arunananth,

Have you checked with your network/firewall team?

>>>client01# telnet localhost 22
Trying...
Connected to localhost.armstrong.com.
Escape character is '^]'.
SSH-1.99-OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5
Connection closed by foreign host.
<<<

This says sshd is running on client01. The most suspect thing is firewall. You need to ask the firewall team to open the port between these two servers.
Best wishes,

Ganesh.
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

I have reported to firewall team.
Rita C Workman
Honored Contributor

Re: SFTP without applying password in script

For sftp I generally have ports 22 -and- port 115 open.

Just a thought,
Rita

...The suggestion to use scp might help you, once your keys are properly in place on both sides, you should only have to put in the password the first time. After that it won't ask for it.....
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

As per Network team there is no block in firewall and the ports are open.

Kindly suggest me to proceed further
Arunananth
Occasional Advisor

Re: SFTP without applying password in script

scp also not working from ssh server to client server.