scp localfilepath ubuntu@1.2.3.4:/tmp scp ubuntu@1.2.3.4:/tmp/filename localfilename
!/bin/bash
UPLOAD A FILE
use a key to upload a file to a specific directory and name on a remote machine
scp -i ~/.sshkeys/aws.pem WriteExample.war ubuntu@compute.amazonaws.com:/var/lib/tomcat6/webapps/WriteExample.war
(if you have the .ppk you can use puttygen to Load the .ppk and Conversions -> Export OpenSSH -> save as key.pem)
specific port
scp -P 2233 -p filename user@host:/path/filename
copy multiple files from one place to another
scp user@host1.com:/path/* user@host2:/path/
get files
scp -r localname.txt user@remoteservername.com:/some/remote/directory/filename.txt
get recursively files from remote server and put them in localservertemp
scp -r remoteservername.com:/home/testuser/* /localservertemp
if you have sshd running then you can scp (hopefully even sftp) (openssl ssh comes by default as an ubuntu apt-get package from the repository, configured by /etc/ssh/sshd_config)
sftp user@host -oPort=7777
ls,cd,pwd,mkdir,rmdir,put,get,ren,chmod AND lls,lcd,lpwd , quit //also you can't use the "tab" auto complete =(
NON INTERACTIVE FTP OVER SSH (the -o SSH option is on by default?)
then you can use a special sftp client (e.g. otherwise filezilla in SFTP mode)
Host: ip address
Port: this is the SSH server port
ServerType: SFTP
Logon: Ask for Password
user: ssh_username
or putty portable contains psftp (command line tool)
PSFTP allows an interactive file transfer session, like a GUI ftp program.
(list directories, browse around, issue multiple get and put commands, etc.)
PSCP is designed to do a single file transfer (securely) and immediately terminate.
if you download putty.zip , http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
cmd.exe
pscp.exe -p -v -P 22 putty.zip user@host-or-ip.com:/home/user
so we're preserving stuff, verbose, Port 22 uploading file putty.zip to the host/directory
pscp.exe -p -v -P 22 -scp putty.zip user@host-or-ip.com:/home/user
force scp mode (not sftp as scp is more universally ssh compatible)
psftp host -P port# -l username -v
you'll be prompted for your password and afterwards away you go with commandline ftp!
help
ls //list files in the current directory dir cd //change directory pwd //print working directory
mkdir rmdir
get filename get filename newfilename put filename put filename newfilename
reget filename //for failed transfers reput filename
ren oldfilename newfilename //rename
chmod
lcd //change local machine directory lpwd //print local machine current directory !ren localfile newlocalfile //run a command on the local directory
del quit