Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Ip of my Windows machine is 172.16.22.53, and it installed cygwin. I want write a bash script like that:

#!/bin/bash 
sshpass -p 'myPassWord' ssh [email protected]
#and some command to run cmd command in the Windows machine.

Is it possible?

That is my try(it log in the Windows machine,and go into cygwin command interface .But don't creat the Catalog(myth) in the Windows machine!):

#!/bin/bash 
sshpass -p 'myPassWord' ssh userNmae@myIp|mkdir myth
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It's really not very clear what isn't working for you. If you just want to run a command remotely, sshpass can help you.

Maybe you just have the syntax a little bit wrong. For example, the following command will login to a remote server, check the uptime and print the uname:

sshpass -p '<password>' ssh <username>@<myIp> "uptime;uname -a"

Note the quoting of the commands.

A better solution might be to use ssh-keygen to login securely without using a password.

This page was helpful: http://www.nextstep4it.com/categories/unix-command/sshpass/

share|improve this answer
    
Oh!God! Thanks! –  orange Dec 13 '13 at 6:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.