# مختصر: ## SCP کپی امن (برنامه کپی فایل از راه دور) This tutorial will demonstrate how to use the scp command through practical examples and detailed explanations of the most commonly used scp options. ## SCP Command Syntax Before going into how to use the scp command, let’s start by reviewing the basic syntax. The scp command syntax takes the following form: ```linux scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2 ``` مثال: ``` scp -r -P 22 admin@192.168.1.1:/home/dir1 /home/ ``` OPTION - scp options such as cipher, ssh configuration, ssh port, limit, recursive copy …etc. * [user@]SRC_HOST:]file1 - Path to the source file. The name of the user on the source machine and the hostname (or the IP address) of the source machine are used when the file is located on a remote machine. * [user@]DEST_HOST:]:file2 - Path to the destination file. The name of the user on the destination machine and the hostname (or the IP address) of the destination machine are used when the file is located on a remote machine. # توضیحات مفصل: ## SCP کپی امن (برنامه کپی فایل از راه دور) Name scp - secure copy (remote file copy program) ## خلاصه: ``` scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [ [user@]host1:]file1 ... [ [user@]host2:]file2 ``` ## Description scp فایل ها را بین میزبان ها در یک شبکه کپی می کند. از ssh(1) برای انتقال داده استفاده می کند و از همان احراز هویت استفاده می کند و همان امنیت ssh (1) را فراهم می کند. برخلاف rcp(1)، scp در صورتی که برای احراز هویت مورد نیاز باشد، رمز عبور یا عبارت عبور را درخواست می کند. نام فایل ممکن است حاوی مشخصات کاربر و میزبان باشد تا نشان دهد که فایل باید در/از آن میزبان کپی شود. نام فایل‌های محلی را می‌توان با استفاده از نام‌های مسیر مطلق یا نسبی صریح کرد تا از استفاده scp با نام فایل‌های حاوی «:» به‌عنوان مشخص‌کننده میزبان جلوگیری شود. کپی بین دو میزبان راه دور نیز مجاز است. هنگام کپی کردن یک فایل منبع به یک فایل هدف که از قبل وجود دارد، scp محتویات فایل هدف را جایگزین می کند (با حفظ inode). اگر فایل مورد نظر هنوز وجود نداشته باشد، یک فایل خالی با نام فایل هدف ایجاد می شود و سپس با محتوای فایل منبع پر می شود. هیچ تلاشی برای انتقال "نزدیک به اتمی" با استفاده از فایل های موقت انجام نمی شود. گزینه ها به شرح زیر است: -1' Forces scp to use protocol 1. -2' Forces scp to use protocol 2. -4' Forces scp to use IPv4 addresses only. -6' Forces scp to use IPv6 addresses only. -B' Selects batch mode (prevents asking for passwords or passphrases). -C' Compression enable. Passes the -C flag to ssh(1) to enable compression. -c cipher Selects the cipher to use for encrypting the data transfer. This option is directly passed to ssh(1). -F ssh_config Specifies an alternative per-user configuration file for ssh. This option is directly passed to ssh(1). -i identity_file Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to ssh(1). -l limit Limits the used bandwidth, specified in Kbit/s. -o ssh_option Can be used to pass options to ssh in the format used in ssh_config(5). This is useful for specifying options for which there is no separate scp command-line flag. For full details of the options listed below, and their possible values, see ssh_config(5). AddressFamily BatchMode BindAddress ChallengeResponseAuthentication CheckHostIP Cipher Ciphers Compression CompressionLevel ConnectionAttempts ConnectTimeout ControlMaster ControlPath GlobalKnownHostsFile GSSAPIAuthentication GSSAPIDelegateCredentials HashKnownHosts Host' HostbasedAuthentication HostKeyAlgorithms HostKeyAlias HostName IdentityFile IdentitiesOnly KbdInteractiveDevices LogLevel MACs' NoHostAuthenticationForLocalhost NumberOfPasswordPrompts PasswordAuthentication Port' PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication RekeyLimit RhostsRSAAuthentication RSAAuthentication SendEnv ServerAliveInterval ServerAliveCountMax SmartcardDevice StrictHostKeyChecking TCPKeepAlive UsePrivilegedPort User' UserKnownHostsFile VerifyHostKeyDNS -P port پورتی را برای اتصال در میزبان راه دور مشخص می کند. توجه داشته باشید که این گزینه با P بزرگ نوشته شده است، زیرا -p از قبل برای حفظ زمان ها و حالت های فایل در rcp(1) رزرو شده است. -p' Preserves modification times, access times, and modes from the original file. -q' Quiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1). -r' Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal. -S program Name of program to use for the encrypted connection. The program must understand ssh(1) options. -v' Verbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems. The scp utility exits 0 on success, and >0 if an error occurs. IPV6 IPv6 address can be used everywhere where IPv4 address. In all entries must be the IPv6 address enclosed in square brackets. Note: The square brackets are metacharacters for the shell and must be escaped in shell.