1828670 Members
2131 Online
109984 Solutions
New Discussion

Command syntax of ssh

 
SOLVED
Go to solution
Jose Marcio Medeiros
Occasional Contributor

Command syntax of ssh

Hi,
I was submitted to an IT exam that have a question about SSH. The answer options are True or False.

Question:
Secure copy of files can be executed remotely with the command
ssh -l user host `cd dir; tar cvf - ./*` |tar xvf -

Is it true?
I know that there is the command scp, but using ssh, is it correct?

Thanx.
3 REPLIES 3
Ralph Grothe
Honored Contributor
Solution

Re: Command syntax of ssh

Provided you want to extract the remote directory tree into the current working directory from where you submitted the ssh command, and provided the remote user has a directory dir in his $HOME this will work fine.

I constantly use similar constructs to move data between hosts.
Madness, thy name is system administration
Michael Armbrecht
Frequent Advisor

Re: Command syntax of ssh

I am not too sure about that '*' wildcard in the ssh command, it might be that it will be expanded by your local shell and not the remote one. You might have to escape it.
Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic.
Ralph Grothe
Honored Contributor

Re: Command syntax of ssh

Michael,

the command string to be executed by the remote shell is already in single quotes.

However, mentioning this issue is a good point.

One has to be careful to quote any shell meta-characters (either by prepending backslashes or by putting them in single quotes) that are intended to be interpreted/epxpanded by the remote shell.
If not these will be expanded by the local shell.
Considering this behavior you can build up complex pipelines.
Madness, thy name is system administration