Fedora 40
Sponsored Link

OpenSSH : SSH दस्तावेज हस्तांतरण (Fedora)2024/04/25

 
SSH के माध्यम से फ़ाइलें स्थानांतरित करना संभव है।
[1] यह SCP (Secure Copy) का उपयोग करने का उदाहरण है।
# आज्ञा ⇒ scp [Option] Source Target
# लोकलहोस्ट पर [test.txt] को रिमोट होस्ट [node01.srv.world] पर कॉपी करें

[fedora@dlp ~]$
scp ./test.txt fedora@node01.srv.world:~/

fedora@node01.srv.world's password:     # उपयोगकर्ता का पासवर्ड
test.txt                                      100%   10     0.0KB/s   00:00

# रिमोट होस्ट [node01.srv.world] पर [/home/fedora/test.txt] को लोकलहोस्ट पर कॉपी करें

[fedora@dlp ~]$
scp fedora@node01.srv.world:/home/fedora/test.txt ./test.txt

fedora@node01.srv.world's password:
test.txt                                      100%   10     0.0KB/s   00:00
[2] यह SFTP (SSH File Transfer Protocol) का उपयोग करने के उदाहरण हैं। SFTP सर्वर सुविधा डिफ़ॉल्ट रूप से सक्षम है,
लेकिन यदि नहीं, तो इसे [/etc/ssh/sshd_config] में लाइन [सबसिस्टम sftp /usr/libexec/openssh/sftp-server] जोड़ने के लिए सक्षम करें।
# sftp [Option] [user@host]

[redhat@dlp ~]$
sftp fedora@node01.srv.world

fedora@node01.srv.world's password:    # उपयोगकर्ता का पासवर्ड
Connected to node01.srv.world.
sftp>

# दूरस्थ होस्ट पर वर्तमान निर्देशिका दिखाएं
sftp> pwd
Remote working directory: /home/fedora

# लोकलहोस्ट पर वर्तमान निर्देशिका दिखाएं
sftp> !pwd
/home/redhat 

# दूरस्थ होस्ट पर वर्तमान निर्देशिका में फ़ाइलें दिखाएं
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            7 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 22:53 test.txt

# लोकलहोस्ट पर वर्तमान निर्देशिका में फ़ाइलें दिखाएं
sftp> !ls -l
total 4
-rw-rw-r--    1 redhat     redhat           10 Apr 24 21:53 test.txt

# निर्देशिका बदलें
sftp> cd public_html
sftp> pwd
Remote working directory: /home/fedora/public_html

# दूरस्थ होस्ट पर फ़ाइल अपलोड करें
sftp> put test.txt redhat.txt
Uploading test.txt to /home/fedora/redhat.txt
test.txt                           100%   10     0.0KB/s   00:00
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:39 redhat.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 22:53 test.txt

# दूरस्थ होस्ट पर कुछ फ़ाइलें अपलोड करें
sftp> put *.txt
Uploading test.txt to /home/fedora/test.txt
test.txt                                           100%   10     0.0KB/s   00:00
Uploading test2.txt to /home/fedora/test2.txt
test2.txt                                          100%    0     0.0KB/s   00:00
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:39 redhat.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:45 test.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:46 test2.txt

# दूरस्थ होस्ट से एक फ़ाइल डाउनलोड करें
sftp> get test.txt
Fetching /home/fedora/test.txt to test.txt
/home/fedora/test.txt                   100%   10     0.0KB/s   00:00

# दूरस्थ होस्ट से कुछ फ़ाइलें डाउनलोड करें
sftp> get *.txt
Fetching /home/fedora/fedora.txt to fedora.txt
/home/fedora/fedora.txt                                       100%   10     0.0KB/s   00:00
Fetching /home/fedora/test.txt to test.txt
/home/fedora/test.txt                                         100%   10     0.0KB/s   00:00
Fetching /home/fedora/test2.txt to test2.txt
/home/fedora/test2.txt                                        100%   10     0.0KB/s   00:00

# दूरस्थ होस्ट पर एक निर्देशिका बनाएँ
sftp> mkdir testdir
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:39 redhat.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:45 test.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:46 test2.txt
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:53 testdir

# दूरस्थ होस्ट पर एक निर्देशिका हटाएँ
sftp> rmdir testdir
rmdir ok, `testdir' removed
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:39 redhat.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:45 test.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:46 test2.txt

# दूरस्थ होस्ट पर एक फ़ाइल हटाएँ
sftp> rm test2.txt
Removing /home/fedora/test2.txt
sftp> ls -l
drwxrwxr-x    2 fedora     fedora            6 Apr 24 21:33 public_html
-rw-rw-r--    1 fedora     fedora           10 Apr 24 21:39 redhat.txt
-rw-rw-r--    1 fedora     fedora           10 Apr 24 Apr 24 21:45 test.txt

# ![command] के साथ कमांड निष्पादित करें
sftp> !cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
.....
.....
redhat:x:1001:1001::/home/redhat:/bin/bash

# बाहर निकलना
sftp> quit
221 Goodbye.
मिलान सामग्री