How to use scp command in conda - anaconda

I'm trying to upload some files onto a remote server but the command scp is not installed on my laptop. I'm working with Anaconda on a Windows 10 machine and the server is a Linux machine with Ubuntu 18.04.
To my intuition, I think it's easier to install scp directly with conda than to install it on Windows (I'm actually using Anaconda Prompt rather than Windows DOS), so following the instruction of Anaconda website I ran
conda install -c remram scp
after which I reran the scp command, only to find scp still not installed.
I have double-checked other dependent tools like ssh and also updated my conda, but nothing worked.
Is it even possible to use scp on a conda environment when there isn't an scp on my computer? If so, what's the correct thing to do to make it available? If not, can anyone share a reliable way to install scp on Windows system?

Related

Possible to use Windows installation of Anaconda in WSL2?

And if so, how to do this?
I've only found instructions on installing anaconda through WSL2 but I already have it installed in Windows.
I found the below snippet to have WSL2 run my windows bash helper that stored my github credentials and was hoping for something similar.
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
Or if I have to install through WSL2 but can use that in Windows that would be fine too. I just would really prefer not to have 2 copies of it.

How to install sshpass on Windows through Cygwin?

In the packages window of CygWin, when I type sshpass, nothing comes up. I tried installing similar packages like openssh etc hoping one of them contains sshpass but no luck.
sshpass is not available as Cygwin package. This means that you need to build and install from source. To build sshpass on Windows (Cygwin):
$ curl -LO http://downloads.sourceforge.net/sshpass/sshpass-1.06.tar.gz
$ md5sum sshpass-1.06.tar.gz
f59695e3b9761fb51be7d795819421f9
Build and install to /usr/local/bin:
$ tar xvf sshpass-1.06.tar.gz
$ cd sshpass-1.06
$ ./configure
$ make
$ sudo make install
Which installs two files
the executable /usr/local/bin/sshpass
man page /usr/local/share/man/man1/sshpass.1
Your Cygwin install needs to have the required tools: curl to download, tar to extract, and autoconf, make and gcc to build. I'll assume reader familiarity with installing packages on Cygwin.
sshpass is not available as cygwin package. This means that you need to build and install from source.
See for reference on existing alternative
https://www.cygwin.com/ml/cygwin/2015-02/msg00042.html
This does not directly answer the question "How to install sshpass on Windows?", but can be much easier solution if you need to automatically enter the password when ssh-ing to a machine on Windows system, you can use Plink (part of PuTTY).
plink your_username#yourhost -pw your_password
Window 10 comes with Linux subsystem, you can install a favor of Linux through Windows Store. Then all Linux commands comes easily. sshpass can be easily installed in the subsystem. WSL(Windwos Subsystem for Linux) is the future.

Can openssh be installed on MSYS?

I'm using MSYS in windows 7 and now i need it to provide ssh server service. can openssh be installed in msys like it is in cygwin?
i can find ssh in /msys/bin, and it can be used as ssh client. but no server seems to be installed. how can i install one? i googled a lot but almost every theads leads to openssh in cygwin, that does not apply to my situation.
i compared cygwin and msys and decide to use msys. We need to run some applications both built and supposed to be ran in windows.
what i've tried:
mingw-get install mysys-openssh
test#WIN-L3L622JBT6G ~
$ mingw-get install msys-openssh
install: openssh-5.4p1-1-msys-1.0.13-bin.tar.lzm
installing openssh-5.4p1-1-msys-1.0.13-bin.tar.
install: openssh-5.4p1-1-msys-1.0.13-doc.tar.lzm
installing openssh-5.4p1-1-msys-1.0.13-doc.tar.
install: openssh-5.4p1-1-msys-1.0.13-lic.tar.lzm
installing openssh-5.4p1-1-msys-1.0.13-lic.tar.
test#WIN-L3L622JBT6G ~
$ openssh
sh: openssh: command not found
the package seems to be installed but i don't know how to find the service. do i need to link it or modify the profile?
The answer would be "NO".
Msys provide ssh client but not ssh server, as it's document indicates.
And Openssh cannot be installed on windows without cygwin. you can install a full cygwin and install openssh in cygwin. It's also feasible to only install partial cygwin.
Msys is outdated. Use Msys2, which does support sshd: https://www.booleanworld.com/get-unix-linux-environment-windows-msys2/

sudo command not found on Cygwin

I am currently trying to install and update a few packages on a Windows OS. The only matter is that I am using Cygwin in order to type the commands through a terminal (as I'm aware, I can type in Linux type commands such as cd, ls etc. on Cygwin - I may be wrong). However, when I try to install a package like:
sudo apt-get install paparazzi-dev
I get the reply:
-sh: sudo: command not found.
Does anyone have an idea as to how I can fix this problem?
Run cygwin as administrator.. then you wouldn't need any sudo command.
Cygwin is not a full Linux distribution. Therefore you don't have sudo or the Debian/Ubuntu package manager apt-get. There is a number of packages available from the Cygwin repository: http://cygwin.com/packages/
You have to chose these packages during setup.
Windows does not have sudo, apt, or almost any Linux commands to be exact. Cygwin may allow some, but as programs are not installed on Windows as packages apt-get will not work. Windows programs have installers as .exe or .msi instead.
The Windows version of sudo is called runas in case you need to run something as another user. Or, you can run Cygwin as administrator.
If you have to use the packages you need Linux. You can install it directly to replace Windows, dual-boot or use a virtualization software like VMware VirtualBox.
Making out an explanatory answer from answer here by #Aimal as it worked for me.
Cygwin may not get permissions to create folders and files when run by clicking Cygwin icon that's in normal mode.
Cygwin gets the right authorization only when right click -> "run as adminitrator" on cygwin icon because of that it gets permissions to create folders and files.
Cygwin lets you run certain commands, such as cd, ls, or mv; but it doesn't let you run other commands, such as sudo or apt-get.
If you're trying to add a package to your Cygwin installation, rerun Cygwin Setup. It may still be in your "Downloads" folder. Go through all the steps again. The Cygwin installer will automatically download and install the package you want, and add it to your Cygwin installation. (I think it will probably also upgrade all your other installed Cygwin packages to the latest available versions.)
If your desired package isn't on the Cygwin package list but is on the Cygwin Ports package list, follow the Cygwin Ports installation instructions. Note that Cygwin Ports is separate from Cygwin. Please do not send messages about Cygwin Ports packages to the cygwin.com mailing lists.
If you have years of Linux experience, you may be able to compile the software you want inside Cygwin. This can be challenging.
Perhaps an option simpler than "compile it yourself" is this: You can install VirtualBox, then install your favorite Linux distribution inside the virtual machine, then install your desired package inside Linux. (I like Ubuntu Linux, which has more than 27,000 packages in its "Universe" repository.) Now you can run Linux and Windows at the same time.
I think I tried steps below after doing some research & succeeded (on windows)
1.Install scoop using powershell 3 (iex (new-object net.webclient).downloadstring('https://get.scoop.sh'))
2. do scoop install --global sudo
3. make sure paths (C:\Users\\scoop\shims & C:\ProgramData\scoop\shims) added in environmental path variable.
In my case, I wanted to install curl, but could not create directory /usr/local/curl/lib when running command "make install", because of permission deny. so i need to change /usr/local permission. when i run sudo chmod 755 /usr/local, sudo command not found.
after searching a few solution, found that sudo is not installed by default in Cygwin. But I tried the solution that Aimal gave which is to run Cygwin as administrator. I finally can change the folder permission. Thanks Aimal.

SFTP command in Bash script with Mac OS X

I need to transfer a text file to a remote PC (freeSSH) using SFTP and SSH from a Mac host. These two are connected in a local network.
So is there a way to run an SFTP command (with the username and password provided) from inside the Bash script?
I already tried some scripting with expect, but I didn't get any results.
I found a similar post, How to run the sftp command with a password from a Bash script, but it is for Linux. I have a Mac.
You can download and install sshpass on Mac as well. Get the latest version source from this download link
Rest of the steps on using sshpass are there in the linked answer of mine.
lftp is great for scripting ftp (and sftp, ftps). And you can install it with brew:
brew install lftp
And for installing the latest version of sshpass using homebrew:
brew install https://raw.githubusercontent.com/EasyG0ing1/sshpassBrew/main/Formula/sshpass.rb
You might have to do this to install it:
wget https://raw.githubusercontent.com/EasyG0ing1/sshpassBrew/main/Formula/sshpass.rb
brew install sshpass.rb
Although #anubhava's answer is correct, it points to the sources only and compiling it without help is hard.
To install sshpass on MacOS using brew easily please use this unofficial package:
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
Source: https://gist.github.com/arunoda/7790979

Resources