copy folder from server to local machine in ubuntu - copy

I have a folder in my server and I tried to copy it in my local machine like:
scp my_username#remotehost.com:/path/to/some_folder /my/local/directory
Inside some_folder there is a folder that I want to copy.
When I run this command it says
/path/to/some_folder/: not a regular file
How can I copy a folder from server to my local machine.
I am using ubuntu 14.04

You can use the -r flag on the scp command
scp -r my_username#remotehost.com:/path/to/some_folder /my/local/directory
From the manual page:
-r' Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal

Easy way, but you need to understand it first. I am using Linux Ubuntu 18.04.4 LTS.
To copy a complete folder with children's from Sever to Local Machine
Just go to local machine empty folder directory. Like my is "results" folder contain on desktop
-r == copy entire folder with all flies
khawar == Username on server Machine
223.120.314.49 == Server IP address
-P == Port
22 == Port Number
/data1/khawar1/lpr/Plate_Recognition-LPRnet/ == Complete directory address of server machine folder that you want to copy
results == folder in local machine
scp -r -P 22 khawar#223.120.314.49:/data1/khawar1/lpr/Plate_Recognition-LPRnet/ results

The easiest and the most interactive way is using sftp; you can manipulate the remote server as of your local machine. Let's say you have the following credentials for your remote server:
. Username: root
. ip: 185.48.22.23
1. Step one: Open your file explorer of your ubuntu local machine
2. Step two: Navigate to 'other locations'
3. Step three: Insert your credentials with sftp on the 'Connect to server' box and press 'connect'.

Related

How to open a remote folder from command line in VS Code?

I can start VS Code to open a local folder using code /path/to/folder. Is it possible to open a folder on a remote machine (via the Remote SSH extension) by specifying the machine and folder on the command line?
From the cli on linux or mac terminal:
code --folder-uri=vscode-remote://ssh-remote+<HOSTNAME><ABSOLUTE_PATH>
Something like:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
In my ~/.ssh/config file I have:
Host centos8stream.local
Hostname 10.41.11.69
User guillaume
In my terminal I can ssh to my server doing ssh centos8stream.local
Then I can open vscode on my remote server directly:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
I even created an alias function in my ~/.zshrc file
function rcode() { code --folder-uri=vscode-remote://ssh-remote+$1/home/guillaume/$2 }
Then I just type
rcode centos8stream.local workspace/my_project
Mount the remote folder in your dev box and open it in VSCode.

Vagrant with Docker set up in Windows - Permisson denied error during rsync

I had set up a vagrant VM with boot2docker for a helloworld docker image on my windows machine. After setting it up, I wanted to sync my host machine windows folder to vm machine. As per instructions, I installed cygwin64 to get rsync on my windows machine.
After setting it up, I tried vagrant up again and I get the following permission denied error during rsync between two machines.
Do I need to set up any permissions on my vm machine?
I accomplished it without changing any permissions.
try this:
1) Open the file located at $cygwin_install_location/etc/fstab
2) replace the last line with none / cygdrive binary 0 0
(This removes the /cygwin/-prefix in its path)
and:
1) edit $vagrant_install_location\embedded\gems\gems\vagrant-1.8.0\plugins\synced_folders\rsync\helper.rb
2) remove the following lines (77-79)
"-o ControlMaster=auto " +
"-o ControlPath=#{controlpath} " +
"-o ControlPersist=10m " +

'ssh' is not recognized as an internal or external command

I have been trying to deploy my app into the Fortrabbit servers using the command line. I'm using windows. Here is what I tried :
C:\projects\riwaya>git remote add fort git#git2.eu1.frbit.com:riwaya.git
C:\projects\riwaya>git remote fort
C:\projects\riwaya>ssh u-riwaya#ssh2.eu1.frbit.com
'ssh' is not recognized as an internal or external command, operable program or batch file.
I have watched This Laracast Video and did the same as Jeffrey but it doesn't work ...
Can somebody help ?
Actually you have 2 problems here: First is that you don't have ssh installed, second is that you don't know how to deploy
Install SSH
It seems that ssh is not installed on your computer.
You can install openssh from here : http://openssh.en.softonic.com/download
Generate your key
Than you will have to geneate your ssh-key. There's a good tutorial about this here:
https://help.github.com/articles/generating-ssh-keys#platform-windows
Deploy
To deploy, you just have to push your code over git. Something like this:
git push fort master
If you get permission denied, be sure that you have put your public_key in the dashboard in the git tab.
SSH
The ssh command gives you access to your remote node. You should have received a password by email and now that you have ssh installed, you should be asked for a password when trying to connect. just input that password. If you want to use your private ssh key to connect to your server rather then typing that password, you can follow this : http://fortrabbit.com/docs/how-to/ssh-sftp/enable-public-key-authentication
For Windows, first install the git base from here: https://git-scm.com/downloads
Next, set the environment variable:
Press Windows+R and type sysdm.cpl
Select advance -> Environment variable
Select path-> edit the path and paste the below line:
C:\Program Files\Git\git-bash.exe
To test it, open the command window: press Windows+R, type cmd and then type ssh.
First of all Go to browser and install openssh here: https://github.com/PowerShell/Win32-OpenSSH/releases
Next step, extract rar file into folder and then copy and paste it in your drive.
after that run command: ssh it should work.
Next step is right click on shh in openssh folder and go to properties. Copy the path
and paste it in system variables in edit environment variables.
It will work fine.
TLDR, add this to settings.json
"terminal.integrated.env.windows":
{
"PATH": "C:/Windows/System32/OpenSSH",
},
Just found a case when the integrated terminal hasn't recognized 'ssh' as command, but you tried 'ssh' that was working on external terminals like CMD, git-bash.
That means you didn't add PATH variable to your integrated terminal.
If anyone looking for solution even now, here is how I did it for my Windows 10 machine.
Start > type 'Manage Optional Features'
Add Feature [+]
Look for OpenSSH client & select & install
After successful installation, open (close if already opened) powershell or command prompt and run ssh!

How to copy a text file through command prompt from a source machine to a destination machine when they are on the same network?

How should I copy a text file say CopyMe.txt from a machine A to a machine B? These two machines are on the same network. Each of these 2 machines need a username and password to log into remotely. I want to achieve this copy action through command prompt.
I have tried using ROBOCOPY command and here is what I have tried step by step:
Get the IP address of machine B say a.b.c.d
Log into machine A and open command prompt
Say the CopyMe.txt file is present on machine A's desktop. So I type the following: ROBOCOPY C:\Users\user_name\desktop\CopyMe.txt \a.b.c.d\C$\Users\user_name\desktop
I get the following error saying Error 5 (0x00000005) Getting File System Type of Destination \a.b.c.d\C$\Users\user_name\desktop\ Access is denied

Copy a non exe File to a Remote Machine

I used PsExec to copy and run an exe file in a remote machine. I also want to copy a xml file to remote machine. I am able to do this way
PsExec.exe -d -c \\someserver c:\somefile.xml
The above command throws error saying system cannot find the file specified but adds the xml file to remote server.
Do u know any better way of copying files to remote server.
Is there any PsTool available for that?
Or an option in PsExec ?
Edit: (Answer)
I found out that using Powershell we can copy file to remote machines and it worked.
As you can read from psexec help
-c: Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the
remote system.
So your xml file is copied on remote sys/USER:[domainname]username]tem and executed, this gives you the error.
If your xml is part of an application you have to run in remote computer, one solution is compress the app with all necessary files in a self-extracting EXE that runs main command when extracted.
If you just have to copy a file, why don't you use a simple script that maps remote folder and then copies file? Something like:
NET USE \\computername\sharename password /USER:[domainname\]username
xcopy .....
NET USE \\computername\sharename /DELETE
PsExec is not designed to copy files across machines. It can only copy the program it is going to run remotely.
If you have access to the remote machine, the copy could be done by running copy c:\somefile.xml \\\\remote-machine\Admin$ before running PsExec.
You can use this pattern with psexec to copy any extension ...
psexec -d -i 2 \PC Name -u domain\username -p password cmd /c copy
\server\location\filename c:\xx\xx\xx
PS: Refer to PSEXEC switches if you're unsure of what -d and i does. However "2" is a session id of remote desktop user that may change every time a new remote desktop session is created.
this helped me copy my exe file into c:\windows directory (one to one copy within same domain) :
PsExec.exe -d -c \\remoteserver -u administrator -p password c:\executable.exe