create text file on remote machine using plink/putty with contents of windows local machine's text file

1

0

I want to basically transfer a small text file ~10kb from a windows local machine to a linux machine through putty/plink. I cant use any file transfer tools like pscp/winscp etc So I'm think of getting my text file content to clipboard on window like this :

in cmd.exe in folder location where plink is present -

type text.txt > redirect this output to plink to create text file

I now want to redirect this clipboard text to plink session so that it could create a text file on the remote linux machine. how to I achieve this? Is this possible?

Abhi

Posted 2018-01-27T09:35:13.077

Reputation: 13

so you can use putty to connect to the remote linux machine but cant use pscp/winscp? how come? I just didn't get what you want to do. If you could explain a bit more. – Zina – 2018-01-27T10:39:21.017

Scp protocol isnt allowed for us as a policy for file transfers...the alternative they use is a slow and not preferred one for me as my file size is very slow and it get for upload in a queque system – Abhi – 2018-01-27T10:44:39.767

This works - type localFile.txt | plink.exe user@remoteserver "cat > path/temoteFile.txt" . My question now is how can I send a zip file this way? – Abhi – 2018-01-27T10:49:52.833

If you have SSH you should have SFTP available (it uses the SSH protocol). On Windows I use the Bitvise SSH Client that gives SSH terminal sessions and a remote file manager based on SFTP (through which you can transfer files). Filezilla also supports SFTP.

– xenoid – 2018-01-27T13:39:26.993

Hi I cannot use any external file transfer clients – Abhi – 2018-01-27T14:50:07.253

Define "cannot use"? Forbidden by some authority? Locked up PC on which you cannot add any executable? – xenoid – 2018-01-27T16:49:01.563

I tried deleting it before I accepted it as the answer. But nevermind it stays now – Abhi – 2018-01-27T11:03:40.940

Answers

2

You don't need a pipeline, just use redirection:

 plink user@host <localfile "cat >hostfile"

This won't work (and neither will piping) if plink needs to prompt for a password; that means you must either:

  • have pageant running with a suitable client key loaded

  • use -i to specify an unencrypted client key (and an unencrypted key is usually a bad idea)

  • use -pw to specify the host password (unless the host prohibits password logons for this user)

dave_thompson_085

Posted 2018-01-27T09:35:13.077

Reputation: 1 962

1

It on remote mashine is bash you can simply run:

cat > remotefile.txt

cat will read input of terminal so you can paste your text and press [ctrl]+[d] to end input. cat will write all text to remotefile.txt

You can verify by:

cat remotefile.txt

this time cat will print remotefile.txt to console.

Or you can use vi or any other editor.

Honza

Posted 2018-01-27T09:35:13.077

Reputation:

This works as follows! this way - type localFile.txt | plink.exe user@remoteserver "cat > path/temoteFile.txt" – Abhi – 2018-01-27T09:44:23.287