Using ssh to add register key on ssh server


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using ssh to add register key on ssh server
# 1  
Using ssh to add register key on ssh server

Hi,

I want to use ssh to add a register key on remote ssh server. Since there are space characters in my register key string, it always failed. If there is no space characters in the string, it worked fine. The following is what I have tried. It seems that "ssh" command doesn't care about double quotes, it just ignores them. Does anyone know how to make it work?

Thanks!

Code:
 C:\>ssh ADM_B REG ADD "HKLM\Software\My Co" /v
cat /t REG_SZ /d 100 /f
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

C:\>ssh ADM_B "REG ADD \"HKLM\Software\My Co\"
/v cat /t REG_SZ /d 100 /f"
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

C:\>ssh ADM_B REG ADD \'HKLM\Software\My Co\' /v
 cat /t REG_SZ /d 100 /f
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

C:\>ssh ADM_B REG ADD 'HKLM\Software\My Co' /v
cat /t REG_SZ /d 100 /f
ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

C:\>ssh ADM_B REG ADD HKLM\Software\MyCo /v cat
 /t REG_SZ /d 100 /f
The operation completed successfully.


Last edited by Scott; 12-17-2009 at 09:27 PM.. Reason: Please use code tags
# 2  
The ssh command does care about double quotes, if it sees them. But cmd.exe doesn't build the arguments right. It doesn't even allow you to escape anything (as you tried) since the backslash is used as path separator.
# 3  
Thank you for reply! So I have to find an alternative to make it work.

---------- Post updated at 12:01 PM ---------- Previous update was at 09:43 AM ----------

I tried to add the register key on server locally. There is no problem when I ran "REG ADD..." directly under command line with space characters in the register key string.
Code:
C:\>REG ADD "HKLM\Software\My Co" /v Data /t REG_BINARY /d fe340ead
The operation completed successfully.

Or if I run ssh to login my ssh server ADM_B first and then run the command above, it still works fine.

Code:
C:\>ssh ADM_B
Last login: Wed Dec  2 15:36:28 2009 from adm_p
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\cygwin\home\AspectRoot>REG ADD "HKLM\Software\My Co" /v cat /t REG_SZ /d 100 /f
The operation completed successfully.

What is the difference between running "ssh" and "REG ADD" in two steps and running both in one command line on client?

Thanks!

Last edited by Scott; 12-18-2009 at 05:33 PM.. Reason: Code tags, please!
# 4  
The biggest question is why are you running windows as your OS
# 5  
In your two examples, this is what REG sees as it's arguments:
  1. ADD
  2. HKLM\Software\My Co
  3. /v
  4. Data
  5. /t
  6. REG_SZ
  7. /d
  8. 100
  9. /f

However, since to the Windows "shell" being very, very, very limited and not allowing nested quotes, this is what your ssh command looks like:
  1. ADM_B
  2. REG
  3. ADD
  4. HKLM\Software\My
  5. Co
  6. /v
  7. cat
  8. /t
  9. REG_SZ
  10. /d
  11. 100
  12. /f

But since you've apparently got Cygwin installed anyways, use the Bash shell that's installed with it, since this shell knows about different types of quotes and how to nest them.
# 6  
I am not well versed with Powershell, but why don't you look into using that? The commands are probably more robust for windows.
# 7  
What happens if you try
Code:
ssh ADM_B 'REG ADD "HKLM\Software\My Co" /vcat /t REG_SZ /d 100 /f'

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #865
Difficulty: Easy
The original idea of a member badging system at UNIX.com was first proposed by Ravinder Singh in 2018.
True or False?

10 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. Cybersecurity

get ssh key comment

Hey Guys, I have a server, and a technical user on it (only for reading logs). I set up openssh, and the user can login only with ssh key pair. Under this one technical user, there are a lots of public keys in the ~/.ssh/authorized_keys file. I would like to find out/log with which key the user... (3 Replies)
Discussion started by: lyynxxx
3 Replies

3. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

4. Shell Programming and Scripting

Generate Public Key when the server is not ssh enabled

I am writing a script that needs to access various servers some of which are not ssh enabled. In order to access the ssh enabled servers I am using the following command to generate the public key : ssh-keygen -t rsa Is there a similar command for the other servers as well. If I try to use... (1 Reply)
Discussion started by: ravneet123
1 Replies

5. UNIX for Advanced & Expert Users

ssh key

Hi all, I have a sshkey which I use to connect from my unix box to a linux box without any issue...... however I downloaded this same key to my laptop and tried to connect to the same linux box but it failed..... As my laptop is running MS Vista I guessing I going have to convert it ...... (1 Reply)
Discussion started by: Zak
1 Replies

6. AIX

SSH has this error: "server refused our key"

I did successful yestday as Porter's doc: 1. Create private/pub key on AIX: $ssh-keygen -t identity 2. Get my private key from the AIX server, found in $HOME/.ssh/identity Put that on Windows box. I use WinSCP to transfer private key from AIX to Windows 3. Run puttygen.exe and... (8 Replies)
Discussion started by: rainbow_bean
8 Replies

7. Cybersecurity

SSH key code versus server key code

Hi, When logging in using SSH access (to a remotely hosted account), I received a prompt to accept a server's key fingerprint. Wrote that string of code down for comparision. Already emailed my host for their listing of the string of code for the server's key fingerprint (for comparison,... (1 Reply)
Discussion started by: Texan
1 Replies

8. AIX

key ssh

hello I want to connect from server1 to server2 (Aix 5.3) with ssh, without password prompt. So i define a ssh-key On server1: ssh-keygen -b 1024 -f identity -P '' -t dsa scp identity.pub toto@server2:/tmp/identity-.pub On server 2: cat identity-.pub >> .ssh/authorized_keys chmod 400... (2 Replies)
Discussion started by: pascalbout
2 Replies

9. Cybersecurity

What's the difference between an SSH Client and an SSH Server?

Eh... yeah. What the title says. :D (1 Reply)
Discussion started by: PSC
1 Replies

10. UNIX for Advanced & Expert Users

Add users on OSX server with SSH

Hi Is it possible to add users on a Mac OSX server from a unix system with ssh? If it is what file to alter? brg Nicke (3 Replies)
Discussion started by: nicke30
3 Replies

Featured Tech Videos