I have a windows 7 laptop (not windows server, just a regular laptop). A unix machine is trying to drop a file to this windows machine. If i don't want to setup an FTP server on my windows, can the unix user still drop files using scp?
This may not be what you are looking for but can accomplish the same goal with relative ease. Using powercat you can set up a listener on the windows box and drop a file from the unix machine.
windows machine (listener):
powercat -l -p 8000 -of C:\file.txt
unix box (using native nc):
nc -nv ip_addr_of_windows_box 8000 < file.txt
Additionally, you could also run a server on the unix box and pull the files from the windows machine over http, though this isn't the safest method as you will be exposing the file system..
unix box:
python -m SimpleHTTPServer
windows (powershell):
Invoke-WebRequest https://ip_of_unix_box:8000/file.txt -OutFile c:\temp\file.txt
Related
I am trying to login into one of the ethernet ports on my development board on ssh from my Windows pc. But it is displaying a message like
'ssh' is not recognized as an internal or external command when i tried to loging into it using ssh root#192.168.4.14.
How to get ssh into my windows system?
I use Linux Bash on my windows to use ssh.
You can install it from your windows configurations. But I think it is only for Windows 10 64bits.
Or if you want, you can install git desktop application. From this you can use linux commands into the git bash.
You can use the below command in command prompt to initiate ssh session.
ssh -l username 192.168.1.1
I am running a local bootstrap.sh script from OSX on a remote Ubuntu server which does some "if else then" stuff to load a specific subscript.sh when a specific condition is met.
I am running that local script with:
ssh user#host "bash -s" <~/projects/projectname/bootstrap.sh
I am having issues with getting the subscript.sh sourced (loaded/included).
You can't. You're only sending the contents of bootstrap.sh to the remote shell. It's attempting to source subscript.sh on the remote machine, and it isn't there.
You'll need to either copy subscript.sh (or both scripts!) to the remote machine, or insert the contents of subscript.sh into bootstrap.sh in place of the source command.
What I would recommend is to rsync your 'bootstrap.sh' from your local computer to your server. You should be able to do this with your ssh credentials.
A very cool utility is Transmit. It is $25 and allows you to cleanly mount your server as if it were a portable hard drive (Transmit can also do synchronizations). All you need is ssh credentials and is very user friendly.
If you are allowed to install on your server, then I would install qsub on it. (Actually just check to see if it is installed.) Then just mount your computer's drive and you can submit scrips with qsub (I actually would just make a small server on your mac). This is what I use for using a linux cluster from my OSX computer.
Alternatively you can make a small server from your osx and have it mounted on your linux server.
Problem Statement- I want to copy some files from remote machine (linux) to my windows machine. I know I can do it using pscp.
I tried looking on the internet, I found several articles, but in those articles I was not able to understand and I was having lot of problems in copying the files from Linx box to Windows.
Can anyone provide me step by step method here, so that I can follow that to transfer files. That will be of great help to me.
I am connected to host cli.vip.host.com using putty and that is linux with username- rkost and password as- password. And I want to copy file a.txt from linux to windows.
Download PSCP from below link
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Run PSCP
Got to command prompt
Use the below code
Copy single file
pscp user#host:remote_path/file_name host_path\file_name
eg: pscp user1#192.168.1.10:/home/user2/a.txt c:\Desktop\a.txt
Copy all files in a folder
pscp user#host:remote_path/* host_path\
eg: pscp user1#192.168.1.10:/home/user2/* c:\Desktop\test\
Copy all files & folders in a folder
pscp -r user#host:remote_path/ host_path\
eg: pscp -r user1#192.168.1.10:/home/user2/ c:\Desktop\test\
For this kind of problem I use all the time netcat. First, you start netcat as server on a machine with an ip IP_address, and afterwards you send the file from the other machine.
nc -l -p <port-number> > out_file
will start it as server in "listen" state, and will save what you send to it in the file "out_file".(check the man page of your version for more parameters.)
From the other machine you send the file something like this:
< file_to_send nc IP_address
(If you want to send an whole directory, you use tar )
I never used it under Windows (because I work as linux engineer). But you can find nc for windows, that work the same as in linux...
if you want to use pscp, you can do this:
pscp -pw password rkost#cli.vip.host.com:/path/to/file c:\path\
if this doesn't work try to add enviroment variable:
set PATH=C:\path\to\putty\directory;%PATH%
After installing POWERSHELL
wow64_microsoft-windows-powershell-exe
you can open the terminal and execute this command line
pscp -r -P Port user#IP:path WINDOWS path
example:
pscp -r -P 2222 user#MyDommain.com:/var/www/html C:\2023\HTML
Make sure you are connected to your vpn server, (i.e. cli.vip.host.com)
use following command from your windows machine
pscp -v rkost#remote_ip_addr:/path/to/file/a.txt c:/some_location/
you can see the verbose with -v flag.
If you wants to copy directory from remote linux machine to your windows
just refer my answer in this
PSCP copy files from godaddy to my windows machine
Is there a way to get current date and time from remote windows machine on linux?
On remote windows machine ssh not enabled, there are no powershell.
Can we achieve result via telnet or smbclient?
You can use the net time command (net is part of SAMBA):
net time -S computername
(the same way you would use net time \computername from Windows)
You must install time service on the remote computer (AFAIR, Windows has built-in time service).
I need to automatically copy files from a linux machine to a windows one every day.
I'm looking for something simple and secure like scp, rsync, sftp. Unfortunately, I'm at a loss of how to set this up on the Windows machine.
Does anyone know how to do this?
You can try mounting the Windows drive as a mount point on the Linux machine, using smbfs; you would then be able to use normal Linux scripting and copying tools such as cron and scp/rsync to do the copying.
You can find rsync for windows in cygwin, with that you can setup a rsync server on the windows box and run a cron job on your linux machine rsync'ing all the files to the windows machine. We used to do that and it worked fine.
"I'm at a loss of how to set this up on the Windows machine." Windows is the client or the server? At a loss means what, specifically? What can't you do?
"linux machine to a windows" can be done two ways.
Linux is client. Windows runs an FTP or SCP or SSH server. Linux has a client and pushes the file to Windows. Look at FileZilla for free windows FTP server. Also, windows often has an FTP service that's turned off. Turn it on.
Windows is client. Windows periodically pulls the file from the linux server. This is easier, since Linux already has all the necessary servers available. You do, howeveevr, need to start them on Linux.
There are scores of sftp, scp clients for Windows. Windows comes with an ftp client. Google for sftp client. You'll find WinSCP, Putty, filezilla, and list free country list of sftp clients.
I haven't used it in years now, but you could try Unison from http://www.cis.upenn.edu/~bcpierce/unison/
It could be done with 'smbclient', which acts much like an FTP client to a Windows share. Check out the manpage: man smbclient and look for ways to script it with the -c option, or man expect to drive it.
Here's how I'd probably do it though:
Pick which user you're going to be
when you sync the files. Log in as
this user and type 'id', and get the
numeric ID. You will use this ID in
step 4
Become 'root'
mkdir /mnt/sharename
Edit your /etc/fstab file and add an entry something like this. Replace the user ID of 500 with your user ID. Replace sharename with your windows share name. Replance WINDOWSHOSTNAME with your host name or IP address. If you don't know the shares, run smbclient -L WINDOWSHOSTNAME.
//WINDOWSHOSTNAME/sharename /mnt/sharename cifs credentials=/root/smblogin,uid=500,noauto,user 0 0
Edit /root/smblogin and put the following two lines in it
username=YOUR_WINDOWS_USERNAME
password=YOUR_WINDOWS_PASSWOD
Log in as the user from step 1.
Try mounting the share: mount /mnt/sharename
If that succeeds, then write a script to do it automatically. Let's call it 'backup.sh':
#!/bin/sh
df | grep -q /mnt/sharename
if test $? -ne 0 ; then
mount /mnt/sharename
fi
cp -r /path/to/dir /mnt/sharename/destination/
Use cron to run the script.
Type crontab -e
Put the following in the file:
PATH=/bin:/usr/bin
# Backup at 2:15 A.M. every day. Run 'man 5 crontab' for help on the time format
15 2 * * * /path/to/backup.sh
You may try WinSCP and its scripting support. And Windows support some kind of cron-like operation in its management stuff, don't they?