automatic ssh into remote server using ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting automatic ssh into remote server using ksh
# 1  
Old 07-03-2007
automatic ssh into remote server using ksh

I still have to enter the password when I want to auto login w/o having to do any command line entry. This code works but I don't want to have to enter the password at the command line. After manning ssh I still am not sure what settings I need to change. Please help. Thanks!


<<<output>>>
$ sh file_exists.ksh
clport@dwebapp1's password:
file exists


<<<code>>>
#!usr/bin/sh

hostname=dwebapp1
login_name=clport

# password=

if [ -n `ssh -l $login_name@$hostname 'ls test/testfile.txt 2>/dev/null'` ]; then
echo file exists
else
echo "file doesn't exist";
fi
# 2  
Old 07-03-2007
Did you set up the SSH keys?
# 3  
Old 07-05-2007
i suggest you to use "expect"
for details man expect

try these site
http://expect.nist.gov/
http://www.io.com/~wazmo/expect.htm
# 4  
Old 07-05-2007
As syndex points out, you need to configure ssh keys correctly for passwordless (i.e. key-based) authentication to work. There are plenty of documents detailing this on the net.

You might also want to look into the Net::SFTP Perl module.

Cheers,
ZB
# 5  
Old 07-23-2007
I set up my keys using ssh-keygen ; copied the key to .ssh/authorized_keys on the remote server. Logged out, logged in and exicuted the script at the beginning of this post and I still was forced to enter command line password. ARGH! I don't understand what I am doint wrong.

The authenticity of host 'dwebapp1 (57.2.20.1)' can't be established.
. key fingerprint is RSA.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no'.
yes
Warning: Permanently added 'dwebapp1,57.2.20.1' (RSA) to the list of known hosts.
clport@dwebapp1's password:
file exists
$ ksh file_exists.ksh
clport@dwebapp1's password:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Help ssh key fail on remote server

Hello everyone, I need some help writing a bash script to: 1. ssh from a jumpserver to 50 remote servers logging in automatically using ssh keys and capture if zabbix is running by running a "ps -ef | grep zabbix" and output to a logfile capturing the server hostname and ps -ef output to... (2 Replies)
Discussion started by: vtowntechy
2 Replies

2. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Shell Programming and Scripting

Multi server access through remote server using ssh

Team, Presently I have 5 ip address kept in ip_abc1 file, for each of the ip address listed, i need to login on each ipaddress one at a time and login as below for that specific ip address ssh -p 8101 karaf@<ip.address_for the specific ip address as logged in> password features:list... (4 Replies)
Discussion started by: whizkidash
4 Replies

4. UNIX for Advanced & Expert Users

Unable to ssh to remote server

Hi, I have two SunOs sparc servers mac1 and mac2. I have exchanged keys between them inorder to passwordless login ssh from mac1 to mac2. However, it is failing after authentication. Part of the debug is as below. Please suggest whats wrong and how do i fix that!! Note: i do not have... (1 Reply)
Discussion started by: mohtashims
1 Replies

5. Shell Programming and Scripting

Script to ssh to remote server

Hi All, I need to prepare a script. Description: Currently i am in server "x(ubuntu os)", here i need to develop a script to ssh to another server "y(ubuntu os)", i have password less authentication to "y". i have done the below #!/bin/bash #ssh to the server "y" and confirming i am... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

6. Shell Programming and Scripting

ksh script with Interactive ssh on remote server

HI Unix Gurus, I an stuck in an interesting issue, where I am trying to execute a script on remote server after ssh. The script on remote server is interactive,. Whenever it is called it hangs where it expects input from terminal and I have to terminate it. I have searched through fourm... (12 Replies)
Discussion started by: Jeevanm
12 Replies

7. Shell Programming and Scripting

ksh not found on remote server

Hi guys, I need to run batch jobs on a remote machine. I have been able to make a connection with a user2 login details via ssh, and have tested that I am in the correct directory etc. Problem is that when I try to run the batch job, I keep getting a ksh <batchjobname> not found. If doing it... (1 Reply)
Discussion started by: Hopper_no1
1 Replies

8. UNIX for Dummies Questions & Answers

Is it possible for a server to be both a remote and client SSH host?

Hi, Not sure if this is possible, I have a server (SERVER1) that is currently set up as a remote SSH host. My client SSH host (SERVER2) is connecting to SERVER1 to scp a file with no password. I now have a need to set up a third server (SERVER3) as a remote SSH host and I need SERVER1 as a... (4 Replies)
Discussion started by: tatchel
4 Replies

9. Shell Programming and Scripting

SSH Remote Server issue

I have a script that connects to remote servers using a public key. Some of the servers are not set up for the public key and I receive the following when I attempt to ssh: The authenticity of host 'XXX' can't be established. RSA key fingerprint is... (1 Reply)
Discussion started by: la_womn
1 Replies
Login or Register to Ask a Question