SLES 15
Sponsored Link

OpenSSH : SSH File Transfer (SUSE)
2019/01/15
 
It's possible to transfer files with SSH.
The follows is for SUSE Clients, but if your Windows is Windows 10 Version 1803 or later like here, OpenSSH Client has been implemented as a Windows feature, so it's possible to use scp, sftp commands like follows with the same usage on Windows command prompt, too.
[1] It's the exmaple for using SCP (Secure Copy).
# command ⇒ scp [Option] Source Target
# copy the [test.txt] on local to remote server [www.srv.world]

suse@dlp:~>
scp ./test.txt suse@www.srv.world:~/

password:    
# password of the user

test.txt                                                100%   10     0.0KB/s   00:00

# copy the [/home/suse/test.txt] on remote server [www.srv.world] to the local

suse@dlp:~>
scp suse@www.srv.world:/home/suse/test.txt ./test.txt

password:
test.txt                                                100%   10     0.0KB/s   00:00
[2] It's example to use SFTP (SSH File Transfer Protocol). SFTP server function is enabled by default, but if not, enable it to add the line [Subsystem sftp /usr/lib/ssh/sftp-server] in [/etc/ssh/sshd_config].
# command : sftp [Option] [user@host]

suse@dlp:~>
sftp suse@www.srv.world

password:    
# password of the user

Connected to www.srv.world.
sftp>
# show current directory on remote server

sftp>
pwd

Remote working directory: /home/suse
# show current directory on local server

sftp>
!pwd

/home/suse
# show files in current directory on FTP server

sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 28 22:53 test.txt
# show files in current directory on local server

sftp>
!ls -l

total 4
-rw-rw-r-- 1 suse suse 10 Jul 29 21:31 test.txt
# change directory

sftp>
cd public_html

sftp>
pwd

Remote working directory: /home/suse/public_html
# upload a file to remote server

sftp>
put test.txt suse.txt

Uploading test.txt to /home/suse/suse.txt
test.txt 100% 10 0.0KB/s 00:00
sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 29 21:39 suse.txt
-rw-rw-r--    1 suse     suse           10 Jul 28 22:53 test.txt
# upload some files to remote server

sftp>
put *.txt

Uploading test.txt to /home/suse/test.txt
test.txt 100% 10 0.0KB/s 00:00
Uploading test2.txt to /home/suse/test2.txt
test2.txt 100% 0 0.0KB/s 00:00
sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 29 21:39 suse.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:46 test2.txt
# download a file from remote server

sftp>
get test.txt

Fetching /home/suse/test.txt to test.txt
/home/suse/test.txt 100% 10 0.0KB/s 00:00
# download some specific files from remote server

sftp>
get *.txt

Fetching /home/suse/suse.txt to suse.txt
/home/suse/suse.txt 100% 10 0.0KB/s 00:00
Fetching /home/suse/test.txt to test.txt
/home/suse/test.txt 100% 10 0.0KB/s 00:00
Fetching /home/suse/test2.txt to test2.txt
/home/suse/test2.txt 100% 10 0.0KB/s 00:00
# create a directory on remote current directory

sftp>
mkdir testdir

sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 29 21:39 suse.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:46 test2.txt
drwxrwxr-x    2 suse     suse            6 Jul 29 21:53 testdir
# remove a directory on remote current directory

sftp>
rmdir testdir

rmdir ok, `testdir' removed
sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 29 21:39 suse.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:46 test2.txt
# remove a remote file

sftp>
rm test2.txt

Removing /home/suse/test2.txt
sftp>
ls -l

drwxrwxr-x    2 suse     suse            6 Jul 29 21:33 public_html
-rw-rw-r--    1 suse     suse           10 Jul 29 21:39 suse.txt
-rw-rw-r--    1 suse     suse           10 Jul 29 21:45 test.txt
# run any command with "![command]"

sftp>
!cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
...
...
suse:x:1001:1001::/home/suse:/bin/bash
# exit

sftp>
quit

221 Goodbye.
Matched Content
 
Tweet