ssh_init: Host does not exist while trying to copy file from pi to my windows pc - pscp

C:\Users\ishan>pscp -i C:\Users\ishan\Private_Key.ppk beegnd-4:/tmp/.satnogs /C:\Users\ishan\OneDrive\Desktop\SatCom is what is used. I am trying to copy iq dumps from my pi.

Related

Unknown hostname error when running SCP from Powershell script

I am trying to write a Powershell script that copies files from a Windows PC to a Linux box.
I am able to SSH into my remote Linux machine from a Powershell window using SSH keys (stored in %userprofile%/.ssh/ on the Windows machine. I can also run an SCP command from the terminal window copying files from the Windows machine to the Linux box.
However, the very same scp command fails when run from a script (script.ps1) with the following error:
ssh: Could not resolve hostname <hostname>: No such host is known.
lost connection
Anyone know why scp cannot resolve the hostname when run as a script in Powershell, when it can from the terminal?
The scp command I am running looks like:
& C:\Windows\System32\OpenSSH\scp.exe -r 'bin/release/net7.0/linux-x64/publish' <user_name>#<comp_name>:/home/<user_name>/containers/net_ws/app
As an aside, I tried to ping the <comp_name> from within the same script and it pings successfully, so there appears to be no issue resolving the comp_name host within the powershell context.
Problem solved, thought full explanation is lacking.
I have solved the script issue by replacing the comp_name with the ip address of the device.
& C:\Windows\System32\OpenSSH\scp.exe -r 'bin/release/net7.0/linux-x64/publish'
<user_name>#<ip_address>:/home/<user_name>/containers/net_ws/app
I'm still curious as to why scp is unable to resolve the ip address from the host name in this instance - i.e. when running as part of a script, rather than in the terminal, especially since other executables running in the same script context are able to find the host.

Matlab connection to a remote server

Is there a way to connect to a host through matlab using SSH? The way that can be done in vscode for example.
I have script and data in the remote machine but matlab license in my local machine. I would like to run the matlab scripts using matlab installed on my laptop.
Alternatively, I clone the scripts on my laptop run them while processing the data located in the remote machine.
https://en.wikipedia.org/wiki/SSHFS
helps you mount a remote filesystem via ssh. So if you can login from your matlab laptop to the data pc via ssh , then sshfs is one step more. From there your data is a path on the matlab laptop.

Configure raspberry pi wifi by writing to micro SD card

I have a raspberry pi but no external keyboard, mouse or ethernet cable to set it up - but I do have micro-sd card reader. Is there a way for me to just write my wireless internet config straight to the micro-sd card so the raspberry pi will be able to connect to the wifi, and then allow me to ssh in?
The micro-sd card already has Raspbian installed on it.
Sure.
Put the card in a drive and mount it.
Go to the partition called boot.
Create an empty file called ssh just using:
touch ssh # Works in Linux/macOS
type NUL >> ssh # Works in Windows
Create a file called wpa_supplicant.conf with your WiFi settings - be very sure that Windows hasn't added any .txt extension:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="NETWORK-NAME"
psk="NETWORK-PASSWORD"
}
Once it works, and you can ssh successfully into the Raspberry Pi, be sure to run:
sudo raspi-config
and permanently enable ssh for subsequent reboots.

Raspberry pi interfacing with windows PC

Hello Friends,
I have a raspberry pi powered with Raspbian OS. I want to create a device which will perform some action like "open calculator ,open notepad,etc" on windows pc by commanding from a raspberry pi. So my problem is how to establish communication between raspberry pi and another windows pc ?
If i use VNC and SSH service, can i invoke other programs remotely on pc ?
You could use netcat, also known as nc which is included in most Linux distros and is available for Windows.
All you would do on the Windows box is get your IP address with:
ipconfig
Then you would start listening on some random port, say 5000 because that has no security restrictions and pass whatever arrives on that port to CMD.EXE for execution:
nc -l -p 5000 -e CMD.EXE
Then, on your Raspberry Pi, you would just do:
nc <WINDOWS_IP_ADDRESS> 5000
Now you can type Windows commands in your Rasperry Pi terminal for execution on the Windows box:
DIR
NOTEPAD
There is a "cheatsheet" here and I am using the technique in the section entitled "Backdoor Shells".
Note that this is a big security hole, but if it is just for yourself playing around on a private network, it is nice and simple.

Run commands on Raspberry Pi when external HDD is connected

I am using a Raspberry Pi to provide network access to a Western Digital media player that has no network interface. The player if just an external HDD and automatically mounts when it is connected.
The problem is that it's HFS formatted, so to be able to read and write it I have to unmount and then remount it with these commands:
sudo umount /dev/sda2
sudo mount -o force -t hfsplus /dev/sda2 /media/wdhdd/
Which works fine, but I don't want to have to SSH in via terminal to run these manually every time I reconnect the HDD.
Is there anyway to auto run a script when an external USB device is mounted?
Because this has to be done every time this USB device is plugged in, you should edit the procedures done when it is plugged in. You can find out more about this by visiting this explanation