When I run an SCP script
scp -W Scp\password.txt -P 22 server:/file_location
scp -W Scp\password.txt -P 22 server:/file_location
in command prompt I get the following prompt:
Do you want to trust this new host key and continue connecting?
Please type 'no','once', or 'always':
As I attempt to type first letter of any option above, it keeps on repeating and prompts the same thing.
Please type 'no','once', or 'always':
Please type 'no','once', or 'always':
Please type 'no','once', or 'always':
How can I resolve this?
I had this same issue and found that it is resolved by copying and pasting the word you are trying to type in. For me I copied the work always and pasted it into cmd.
Related
I'm trying to connect to my server via SSH and issue some commands to it. For some reason it seems like the commands are getting cut "off".
Here is the code that does the putty connection as well as issuing the SSH commands:
./plink.exe ${USER}#${HOSTNAME} -pw ${PASS}<<SSH
cd /some/foo/bar
deploy_artifact.sh --instance development1 some_artifact.ear
APP_development1.sh restart
exit
SSH
For me it works, but on the machine of my colleague the issued SSH commands are getting cut off and thus are not interpreted correctly. For example deploy_artifact.sh is getting turned into ploy_artifact.sh (See the following the screenshot).
How can i prevent this? And what is causing this?
Thanks in advance for any help!
It appears the problem is with the plink and how it is used. The given example sends commands as a standard input, however I did not find in the plink manual any mention that it reads commands from the STDIN. It is better to avoid undocumented features, since they may not work correctly or the author may remove them without any notice. Instead, if you want to pass commands inline you should provide them as an argument, ie you either have to use a quoted text, or you can wrap heredoc in the "$(cat *heredoc* )" code, eg:
./plink.exe ${USER}#${HOSTNAME} -pw ${PASS} "$(cat <<SSH
cd /some/foo/bar
deploy_artifact.sh --instance development1 some_artifact.ear
APP_development1.sh restart
exit
SSH
)"
Or, you can keep the commands in a file and run the plink with the -m commands_file option.
I've read all the threads that I could find regarding this issue that I am having, however I have not yet found a solution to my problem.
First let me say that I am currently attempting to do this work in a very restrictive environment so I do not have the option of messing with configurations or any other admin type functions.
code:
ssh -t username#host "sudo -u user hadoop fs -ls /"
running this returns the output that I am looking for, however the next line will hang and does not assign the output to the variable:
output=$(ssh -t username#host "sudo -u user hadoop fs -ls")
I have attempted any and all variations of this line that I could find. If I do an echo of the variable it just spits out a blank line. The reason for the -t option is becuase without it I was getting an error along the lines of:
sudo: no tty present and no askpass program specified
sudo: pam_authenticate: Conversation error
I really don't have any contingency plans if I can't get this single line to work, so if you can help, it would be greatly appreciated.
Please give this a shot. I was able to do it at least 10 times in a row
output=$(sshpass -f <(printf '%s\n' $password) ssh user:#host "sudo ls");
echo $output;
This command is using sshpass to pass the password non interactively to the ssh command.
I'm trying to execute a bash file with putty/plink but gives me an error.
On windows Ive got this batch:
E:\putty\plink.exe user#link -pw password -m E:\folder\test.sh
on bash file Ive got this:
#!/bin/bash
vtoff
vtadmin check connector /PCS/ConnectionModels/Arbor/
and the error:
C:\folder>e:\folder\test.bat
C:\folder>e:\putty\plink.exe user#link -pw password -m e:\folder\test.sh
ksh[4]: vtoff: not found
ksh[5]: vtadmin: not found
C:\folder>
The documentation for plink says that -m specifies that it should "read remote command(s) from file".
Since #!/bin/bash isn't a command, and your error message references ksh, it's pretty clear that bash is nowhere to be found in this question!
As for your actual error message, it seems that the commands aren't found, probably because they're not in your PATH.
I've spent the better part of 8 hours trying to figure this out with google, so I hope this warrants asking here.
I need a script that will auto-enter a password when I try to connect from my lubuntu image in vmware to a physical device connected by usb.
I've tried at least 50 different scripts I've found online, but none of them worked (or even recognised spawn as a command)
This is my script:
#!/usr/expect
spawn CPY2T_old.sh
expect "root#10.9.8.2's password:"
send "ThePassword"
expect eof
The contents of CPY2T_old.sh is
#!/bin/bash
cd hellolinux/src/Exercise$1
scp $2 root#10.9.8.2:
The above bash script works fine, but I have to enter the password, which is what I'm trying to avoid in the first place. The expect script gives the following when I execute in cmd:
spawn: command not found
couldn't read file "root#10.9.8.2's password:": no such file or directory
The program 'send' can be found in the following packages:
* mailutils-mh
* nmh
Try: sudo apt-get install <selected package>
couldn't read file "eof": no such file or directory
I've downloaded mailutils and nmh at least a dozen times by now as well. Elsewhere I read I need to #echo off at the top, but this command isn't recognised and gives an error.
EDIT: I can't do passwordless ssh to this device, so please don't suggest it.
I see 2 errors: first
#!/usr/expect
You want
#!/usr/bin/expect
That should have caused an error: how are you launching your expect script?
Second
send "ThePassword"
You forgot to hit enter
send "ThePassword\r"
#!/usr/bin/expect
set timeout 60
spawn ssh user#ip
expect "user#ip's password: "
send "Password\r"
interact
Note:Please be sure of all scripts are executable with command $ chmod +x #file_name or $ chmod 700 #file_name.
\r to execute
Github link:https://github.com/asarari207/Lunix_sh
I want to open a new terminal and ssh to a remote machine in the opened terminal, and this terminal has to be kept open so that it can be used later to work on.
I tried the command : gnome-terminal -x ssh user#IPaddress. But I am unable to give any commands in the newly opened terminal.
Can anyone please tell me where I am wrong and correct me?
Thanks in advance,
Saeya
I just tested exactly the code you wrote (inserting a valid user and ip, of course) and it worked fine, so I can't see where you've gone wrong.
if your session is timing out once it is established you can add the ServerAliveInterval option to the command line
gnome-terminal -e 'ssh -o ServerAliveInterval=60 -l user server'
The following command worked successfully : gnome-terminal --window-with-profile=NOCLOSEPROFILE -e "ssh -X $user#$IPaddress".