- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to telnet & ftp without login id & password...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 12:24 AM
08-21-2001 12:24 AM
Script to telnet & ftp without login id & password entry
My job requires me to frequently telnet/ftp to other servers to access or send data. However, some login ids & passwords are too long to be entered manually. I am thinking of setting up a script to telnet/ftp to the the sever. Meaning by entering a simple "telnet server", the system will be able to connect to the remote server without me entering the login id & password. I know I will need to create a text file to keep the login id & password.
Thanks for all the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 01:20 AM
08-21-2001 01:20 AM
Re: Script to telnet & ftp without login id & password entry
Rlogin can be configured to achieve your requirement instead of telnet.
& rcp can be used instead of ftp.
This will avoid keeping passwords in a text file.
To enable rlogin work without prompting password for a user ( user1) from server1 to a user ( user2 ) on server2 you will need to do the following:
In Server1 :
Create a file .rhosts in the home directory of user1 with following contents
Server2 user2
/etc/hosts.equiv should contain
Server2
In Server2
Create a file .rhosts in the home directory of user2 with following contents
Server1 user1
/etc/hosts.equiv should contain
Server1
For more information refer to ?man hosts.equiv?
After the above configuration user1 from server1 can rlogin to server2 as user2 without password. ( same with rcp also )
Hope this helps.
Jagadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 02:24 AM
08-21-2001 02:24 AM
Re: Script to telnet & ftp without login id & password entry
One of my HP-UX servers had the OpenView server distribution on it that comes with Expect. I created a text file with the hostnames in one column, and the root passwords in the other, then encrypted the file using crypt. Then a Bourne Shell script prompted for the hostname as arg 1, and arg 2 as either telnet or ftp, then prompted for the password to decrypt the password file, grep'ped for the hostname in the password file and took the 2nd field with the password, and then passed both hostname and password, and connection method as arguments to an Expect script that did either an ftp or telnet as required...logged-in for me as root and then handed-off.
To be reasonably safe you could encrypt the text file several times with different passwords to increase its robustness.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 02:44 AM
08-21-2001 02:44 AM
Re: Script to telnet & ftp without login id & password entry
You better may use the remote copy command "rcp" which didn't ask for anything if you configure your .rhosts file.
example :
Consider server1 ( local ) and server2 ( remote )
1. Edit the file ".rhosts" in the home directory of the user who will issue the remote command "rcp" on the remote server "server2".
2. Add the following line:
server1 +
3. set permissions on that file ".rhosts" to 400 :
#chmod 400 .rhosts
4. On your local server ( server1 ) issue the command :
#rcp -p -r server2:/home/user1/ex01 remoteEx01
This will copy recursively ( option "-r" ) the directory /home/user1/ex01 on node server2 to server1 local directory with the name remoteEx01.
Notice : "-p" option will preserve ( duplicate ) modification times and modes ( permissions ) of source files, ignoring the current setting of your actual umask file creation mode mask. If this option is specified, rcp preserves the sticky bit only if the target user is superuser.
Synatxe:
#rcp -p -r
sourceServer or destinationServer could be exclusively optional.
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 04:43 PM
08-21-2001 04:43 PM
Re: Script to telnet & ftp without login id & password entry
Thanks for your help. However, the other server I am accessing to is a customer server and I cant do any editing in there. Well the idea of rlogin is good. But if I managed to configure the servers, do I need to borther about login id & password ?
Maybe a shell script is enough for me. Can anyone shows me a sample script to read in the text file with the login id & password ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 08:38 PM
08-21-2001 08:38 PM
Re: Script to telnet & ftp without login id & password entry
Also, make sure the permission on .rhosts is 600! Only the owner can read or write the file. Test with: remsh remote-system pwd
For ftp, it is actually easier: create a file called .netrc in your local system. Change the pwermissions to 600 (very important) and read the man page for ftp which describes the format. Now you can simply type: ftp remote-system and you are immediately logged in.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 11:12 PM
08-21-2001 11:12 PM
Re: Script to telnet & ftp without login id & password entry
it works with the rlogin staff but I still need to update the /etc/hosts.equiv to get things going. However, can someone provide me a solution by writing a script which reads in a text file containging the login id and password for telnet & ftp usage ??
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2001 12:15 AM
08-22-2001 12:15 AM
Re: Script to telnet & ftp without login id & password entry
machine host1 login user1 password pass
The words "machine", "login", and "password" are constants. Replace the word after each constant with the appropriate values. Make 1 line/entry for each host that you want to be automatically logged into. Everytime you ftp a host, your system will first check the ~/.netrc file if you have configured auto login for that host. If you have, then your system will automatically log you in! :)
Hope that helps!
Cheers!
Kherwin :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2001 02:27 AM
08-22-2001 02:27 AM
Re: Script to telnet & ftp without login id & password entry
For ftp it is quite simple using a HERE document:
for HOST in `cat hostlist`
do
ftp -v -n $HOST << HERE
user username passwd
put file
bye
HERE
done
offcourse you can use variables for username and passwd.
For telnet it is a bit trickier since telnet expects a tty port. You can use "expect" or the following example which we use to change the passwd of a user on multiple systems:
for HOST in `cat hostlist`
do
( sleep 2
echo root
sleep 2
echo ${rootpasswd}
sleep 2
echo "passwd ${username}"
sleep 2
echo p # when trusted system
sleep 2
echo "${userpasswd}"
sleep 2
echo "${userpasswd}"
sleep 2
echo exit
sleep 5 ) | telnet $HOST
done
The sleeps are necessary to slow the echo statements.
Offcorse other commands than "passwd" can be issued.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2001 08:46 AM
08-22-2001 08:46 AM
Re: Script to telnet & ftp without login id & password entry
This offers compressed, incremental, encrypted filetransfer without the need to specify passwords at all:
http://www.securityportal.com/cover/coverstory20000814.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2006 09:39 PM
09-04-2006 09:39 PM
Re: Script to telnet & ftp without login id & password entry
mine is suryabanerjee2002@yahoo.co.in