SCP & SSH by Windows 10 PowerShell CLI Command Line Interface
Video Instructions
Back-Up Your Files, Folder, and Data!!
MAKE BACKUPS OR COPIES OF YOUR IMPORTANT FILES!!! Google the cp command in Linux.Or use OneDrive.
See Office 365 -- OneDrive.
Or Github or Gitlab or some other solution.
FILES CAN BE BE REPLACED OR COPIED OVER WITHOUT ANY WARNING!
Quick Tips
Examples are in next section below. This section provides quick tips.
- SCP or Secure Copy Protocol lets you securely copy files or folders between two machines/computers/servers/hosts.
- scp is the CLI command, or Command Line Interface command.
- scp needs you to specify the source you are copying from & destination to copy to.
So...
scp source_file_or_folder destination_file_or_folder - Specify source (where you copy from) 1st & destination (where you copy to) 2nd.
- Always refer to the machine you are *not on* with userid@host:/file/folder/path
- Always refer to the machine you are *on* with just /file/folder/path
- Check file paths. Mistyped file paths are a very common error.
PowerShell vs cmd.exe Tips
- SSH can now be done in cmd.exe Command Prompt or Powershell.
- But make sure OpenSSH client is installed in Windows.
To verify, go to Start menu > Settings > Apps > optional features > scroll down and look for OpenSSH.
This adds SSH functionality to Windows,
and the user can use SSH from the Command Prompt (cmd.exe) or PowerShell. - PowerShell is recommended over cmd.exe. PowerShell lets you use more Unix/Linux commands. Though Powershell may give a disconnect error.
- Cmd.exe has MS-DOS-based command. (Use dir for ls.)
- We recommend running both as Administrator.
Search for PowerShell or cmd.exe in Start menu or lower right search bar.
Before clicking to open Powershell or cmd.exe,
look for option to "Run as Administration," and click it.
Click "Yes" to agree to allow the program to make changes to your computer.
Using SSH
DO NOT use the ssh command at all in the same Terminal window.
If you ssh into Tux, you won't be able to scp to/from your local computer (normally).
Commands below:
or...
ssh mjg88@tux.cs.drexel.edu
- Connect to remote Tux host.
- A password prompt will then be displayed. Please type in your password it will remain invisible the whole time. Once you type it in, simply hit Enter or Return key on your keyboard.
Using SCP with cmd.exe
Below are example of how to use SCP.
For ALL of these examples:
- Win10userID is your Windows 10 (or 11+) login userid.
- "yourTuxUserid" is your Tux userid.
- Do not use mjg88 as either your Tux or Windows 10 (or 11+) userid.
- mjg88 is an example for either userid.
- pwd command prints outs (shows you) your current folder (working directory) and the full file or folder path of it
- ls command lists the files or folders in the current folder (working directory)
- cd /path/to/folder changes directory, or navigates to, a different directory or folder
- cd sub_folder_name changes directory, or navigates to, a sub-directory or sub-folder of the current folder or directory you are in.
- cd ../ changes to the parent directory or goes up one folder level
- cd changes directory to your home directory or folder
Example 1
scp yourTuxUserid@tux.cs.drexel.edu:test.txt "C: \Users\Win10userID\OneDrive - Drexel University\Desktop"\
or...
scp mjg88@tux.cs.drexel.edu:test.txt "C: \Users\mjg88\OneDrive - Drexel University\Desktop"\
- Copying the test.txt file from your remote Tux home folder to your local Windows PC computer's desktop folder.
- Quotes needed around the Desktop folder path on your computer because of the spaces in the OneDrive folder name.
- Also, need a backslash or \ after the quoted file path to indicate it's a folder.
Example 2
scp yourTuxUserid@tux.cs.drexel.edu:test.txt .
or...
scp mjg88@tux.cs.drexel.edu:test.txt .
- Copying a file named test.txt from your remote Tux home folder to your local Windows PC computer.
- The period at the end indicates that the file will be copied to the current directory or folder you are in within cmd.exe or PowerShell.
Example 3
scp test.txt yourTuxUserid@tux.cs.drexel.edu:test.txt
or...
scp test.txt mjg88@tux.cs.drexel.edu:test.txt
- Copying a file named test.txt from your local Windows PC to your remote Tux home directory.
- You already navigated in cmd.exe or PowerShell to the folder (directory) on your local Windows PC that you want to copy the file from.
Example 4
scp C:\Users\Win10userID\Downloads\test.txt yourTuxUserid@tux.cs.drexel.edu:test.txt
or...
scp C:\Users\mjg88\Downloads\test.txt mjg88@tux.cs.drexel.edu:test.txt
- Copying a file named test.txt from your local Windows PC's Downloads folder to your remote Tux home directory.
Example 5
scp yourTuxUserid@tux.cs.drexel.edu:test.txt C:\Users\Win10userID\Downloads\
or...
scp mjg88@tux.cs.drexel.edu:test.txt C:\Users\mjg88\Downloads\
- Copy the file test.txt from the remote Tux host to your local Windows PC's Download folder
Example 6
scp C:\Users\Win10userID\Downloads\test.txt yourTuxUserid@tux.cs.drexel.edu:
or...
scp C:\Users\mjg88\Downloads\test.txt mjg88@tux.cs.drexel.edu:
- Copy the file "test.txt" from your local Windows PC's Desktop folder to the remote Tux host
- Note: If you forget the colon or : at the end, you will just create a file named "yourTuxUserid@tux.cs.drexel.edu" or "mjg88@tux.cs.drexel.edu" in whatever folder or directory you type this command in the cmd.exe or PowerShell.
Example 7
scp -r test_folder/ yourTuxUserid@tux.cs.drexel.edu:test_folder
or...
scp -r test_folder/ mjg88@tux.cs.drexel.edu:test_folder
- Copy the folder "test_folder" (with a file inside) from your local Windows PC to the user's remote Tux host home directory
Example 8
scp -r test_folder/ yourTuxUserid@tux.cs.drexel.edu:test-folder-newnameor...
scp -r test_folder/ mjg88@tux.cs.drexel.edu:test-folder-newname
- Copy
the folder "test_folder" from your local Windows PC to the your remote Tux host home directory, and rename it as "test-folder-newname".
Example 9
scp -r "C:\Users\Win10userID\Downloads\test folder"\ yourTuxUserid@tux.cs.drexel.edu:/home/yourTuxUserid/
or...
scp -r "C:\Users\mjg88\Downloads\test folder"\ mjg88@tux.cs.drexel.edu:/home/mjg88/
- Copy the folder "test folder" (space in the name) from your local Windows PC to your remote Tux host home directory.
Example 10
scp .\test_folder\test.txt yourTuxUserid@tux.cs.drexel.edu:or...
scp .\test_folder\test.txt mjg88@tux.cs.drexel.edu:
- Copy the file "text.txt" within the sub-folder or sub-directory "test_folder" from your local Windows PC to your remote Tux host home directory.
- This copies only that file. Not the entire sub-folder or sub-directory.
- We're not renaming the file. And we're placing it at the top of level of your remote Tux host home directory. So no need to specify a folder or sub folder or file name nor a path to a file, folder, or directory.
Example 11
scp test.txt yourTuxUserid@tux.cs.drexel.edu:test-folder2\
or...
scp test.txt mjg88@tux.cs.drexel.edu:test-folder2\
- Copy the file "test.txt" from your local Windows PC to the sub-folder or sub-directory "test-folder2" to your remote Tux host home directory.
cmd.exe or Command Prompt Tips
To use SCP with the cmd (Command Prompt) on a Windows device:
- Search 'cmd' in the bottom left search bar
- Select 'Command Prompt' and click on 'Run as administrator'
- A window will pop up asking to allow the app to make changes to your computer, select 'Yes'
- In the cmd, you can change directories by typing 'cd' and click on the 'Enter' key.
Use 'cd ../..' to [Ask later] - Use 'dir' to displays a list of a directory's files and subdirectories. The command displays the disk's volume label and serial number, followed by a list of directories and files on the disk (including filenames, date, and last modified).
- Use 'cd Desktop' to change the directory to the computer's Desktop directory.
- When moving files/folders, do NOT use 'mv'. Use 'move {filename you want to move} '{Desired location to put the file}'