ssh to sftp server code example

Example 1: sftp connect ssh

# Default port is 22
sftp your_user@your_server_ip_or_remote_hostname
# Connexion with a custom port
sftp -oPort=custom_port your_user@your_server_ip_or_remote_hostname

Example 2: ssh sftp example

# Connexion to default port 22
sftp your_user@your_server_ip_or_remote_hostname
# SFTP get local directory
sftp> lpwd
sftp> lls			# list of files in local directory
sftp> lcd mydir		# change local directory
# SFTP get remote directory
sftp> pwd
sftp> ls			# list of files in remote directory
sftp> cd mydir		# change remote directory
# put single file from local to remote directory
sftp> put myfile
# put multiple files from local to remote directory
sftp> mput *.txt
# get single file from remote to local directory
sftp> get myfile
# put multiple files from remote to local directory
sftp> mget *.txt