LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Thread Tools
Old 05-13-2008, 04:37 AM   #1
zerocool22
Member
 
Registered: Feb 2008
Posts: 95
Thanked: 0
putty ssh batch


[Log in to get rid of this advertisement]
Hey, I have putty on my windows machine, but now i want to create a batch file or a vbs script that lets me log in with putty to my linux server and then use ssh. But i dont know how to start with this, can someone help me out?

.bat
fullpath/putty.exe ipadres loginnameserver passwordserver ssh loginname password?
zerocool22 is offline     Reply With Quote
Old 05-13-2008, 05:22 AM   #2
zerocool22
Member
 
Registered: Feb 2008
Posts: 95
Thanked: 0

Original Poster
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "putty.exe 192.168.24.131 -l root -pw Password"
WScript.Sleep 2000
WshShell.AppActivate "192.168.24.131 - PuTTY"
WshShell.SendKeys "conf term{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "int e0{ENTER}"

So he does open putty and prob logs in the server, cause he gives in the username"root" but then the screen pops off? What im doing wrong here? help!
zerocool22 is offline     Reply With Quote
Old 05-13-2008, 05:38 AM   #3
Netguard
LQ Newbie
 
Registered: Jul 2007
Posts: 2
Thanked: 0
putty ssh batch

if you insist on using vbs then just correct the run line to:
putty.exe "192.168.24.131" -l root -pw "Password"
it pops off because you probably have special chars in your password like &

i would go with a simple batch cmd script:

ssh.cmd
========
@echo off
path\to\putty.exe "putty-session-name" -l root -pw "password"
exit
Netguard is offline     Reply With Quote
Old 05-13-2008, 10:41 AM   #4
zerocool22
Member
 
Registered: Feb 2008
Posts: 95
Thanked: 0

Original Poster
hey on my earlyer script i tried WshShell.Run "@{ENTER}" and he doesnt show the @ symbol why is that? i also tried WshShell.SendKeys "@{ENTER}"
zerocool22 is offline     Reply With Quote
Old 05-13-2008, 10:47 AM   #5
zerocool22
Member
 
Registered: Feb 2008
Posts: 95
Thanked: 0

Original Poster
hey thx for the batch script alons@secvsn.com
how can i set the next line to execute to be,
ssh user@localhost ?

thx
zerocool22 is offline     Reply With Quote
Old 05-14-2008, 09:18 AM   #6
Netguard
LQ Newbie
 
Registered: Jul 2007
Posts: 2
Thanked: 0
putty ssh script

you mean run another instance of ssh connection or pass a command to the putty session ?
Netguard is offline     Reply With Quote
Old 06-19-2009, 12:41 AM   #7
skipper_penguin
LQ Newbie
 
Registered: Jun 2009
Posts: 3
Thanked: 0
i´ve the same question..

Quote:
Originally Posted by Netguard View Post
you mean run another instance of ssh connection or pass a command to the putty session ?
hi!.. my question is ..how to pass a command to the putty session?
skipper_penguin is offline     Reply With Quote
Old 06-19-2009, 01:12 AM   #8
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Thanked: 126
Don't know quite what you are trying to do, but have you looked at plink, a command liner version of putty?
billymayday is offline     Reply With Quote
Old 06-19-2009, 10:47 AM   #9
skipper_penguin
LQ Newbie
 
Registered: Jun 2009
Posts: 3
Thanked: 0
I've created a .bat file with this line:
start D:\TEMP\putty.exe -ssh user@server.com -pw password

That opens a putty session and logged in it with the user and password i've already specified. But now, I want to enter a simple command like "ls -l" for example.. How can I do that?

I've also tried plink...The line in that case is this one:
start D:\TEMP\plink.exe -v -ssh user@server.com -pw password -m UNIX_commands.txt

and in that file "UNIX_commands.txt" I've added the following lines:
set -o emacs
cd Temp/data/capture
ls -l

all works fine (the commands are executed) but i can't see the putty session... all i can see is the verbose in my DOS windows of the last line "ls -l"...
skipper_penguin is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[putty&ssh] Who is really good & expert in ssh https tunnelling and firewalling ? Xeratul Linux - General 12 12-03-2006 04:22 AM
putty and ssh trouble section31 Linux - Software 5 08-13-2006 11:24 AM
SSH and Putty... Linux~Powered Linux - Security 4 06-15-2006 03:50 PM
putty,ssh etc problems Braveheart1980 Linux - General 10 01-06-2006 01:46 PM
SSH using putty rkemp Linux - Networking 3 03-06-2004 06:04 PM


All times are GMT -5. The time now is 01:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration