Getting Basic Info Like Hostname and IP
(base) C:\Users\ashish>hostname CS3L (base) C:\Users\ashish>ipconfig Windows IP Configuration Ethernet adapter Ethernet 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : ad.itli.com Ethernet adapter Ethernet: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : ad.itli.com Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : IPv6 Address. . . . . . . . . . . : 2401:4900:47f2:5147:b1b2:6d59:f669:1b96 Temporary IPv6 Address. . . . . . : 2401:4900:47f2:5147:15e3:46:9f5b:8d78 Link-local IPv6 Address . . . . . : fe80::b1b2:6d59:f669:1b96%13 IPv4 Address. . . . . . . . . . . : 192.168.1.100 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : fe80::d837:1aff:fe40:b173%13 192.168.1.1 Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :Setting up SSH
(base) C:\Users\ashish>mkdir .ssh (base) C:\Users\ashish>dir Volume in drive C is OSDisk Volume Serial Number is ABCD-PQRS Directory of C:\Users\ashish 10/26/2022 03:25 PM <DIR> . 10/26/2022 03:25 PM <DIR> .. 08/16/2022 01:29 PM <DIR> .3T 09/26/2022 08:04 AM 1,288 .bash_history 06/02/2022 10:15 AM <DIR> .cache 05/30/2022 11:39 AM <DIR> .conda 10/26/2022 02:58 PM 89 .dotty_history 08/19/2022 06:42 PM 68 .gitconfig 10/11/2022 02:03 PM <DIR> .ipython 05/30/2022 10:05 AM <DIR> .jupyter 05/30/2022 12:56 PM <DIR> .keras 08/20/2022 11:55 AM 20 .lesshst 07/04/2022 06:09 PM <DIR> .matplotlib 06/30/2022 10:32 AM <DIR> .ms-ad 10/07/2022 09:00 PM 1,457 .python_history 10/26/2022 03:25 PM <DIR> .ssh 09/06/2022 10:13 PM 2,379 .viminfo 05/30/2022 11:34 AM <DIR> .vscode 05/16/2022 03:19 PM <DIR> 3D Objects 10/07/2022 02:50 PM <DIR> Anaconda3 05/16/2022 03:19 PM <DIR> Contacts 10/26/2022 02:57 PM <DIR> Desktop 10/07/2022 06:27 PM <DIR> Documents 10/26/2022 03:18 PM <DIR> Downloads 05/16/2022 03:19 PM <DIR> Favorites 05/16/2022 03:19 PM <DIR> Links 05/16/2022 03:19 PM <DIR> Music 05/16/2022 02:13 PM <DIR> OneDrive 05/16/2022 03:20 PM <DIR> Pictures 05/16/2022 03:19 PM <DIR> Saved Games 05/16/2022 03:20 PM <DIR> Searches 05/30/2022 09:36 AM <DIR> Videos 6 File(s) 5,301 bytes 26 Dir(s) 81,987,842,048 bytes free (base) C:\Users\ashish>cd .ssh (base) C:\Users\ashish\.ssh>dir Volume in drive C is OSDisk Volume Serial Number is ABCD-PQRS Directory of C:\Users\ashish\.ssh 10/26/2022 03:25 PM <DIR> . 10/26/2022 03:25 PM <DIR> .. 0 File(s) 0 bytes 2 Dir(s) 81,987,903,488 bytes free (base) C:\Users\ashish\.ssh>echo "" > id_rsa (base) C:\Users\ashish\.ssh>dir Volume in drive C is OSDisk Volume Serial Number is ABCD-PQRS Directory of C:\Users\ashish\.ssh 10/26/2022 03:26 PM <DIR> . 10/26/2022 03:26 PM <DIR> .. 10/26/2022 03:26 PM 5 id_rsa 1 File(s) 5 bytes 2 Dir(s) 81,987,678,208 bytes free (base) C:\Users\ashish\.ssh>type id_rsa (base) C:\Users\ashish\.ssh> (base) C:\Users\ashish>ssh-keygen -t rsa -f ./.ssh/id_rsa -P "" Generating public/private rsa key pair. ./.ssh/id_rsa already exists. Overwrite (y/n)? y Your identification has been saved in ./.ssh/id_rsa. Your public key has been saved in ./.ssh/id_rsa.pub. The key fingerprint is: SHA256:fGEZHROeTzogrdXwo7haw0g3eXLVZnO9nM0ZtTbIBh8 itlitli\ashish@CS3L The key's randomart image is: +---[RSA 3072]----+ | oo+E .| | . B=+o +| | . B B=*=o| | . B =.Bo+B| | . S = o .=o| | . + B . | | . = | | o . | | . | +----[SHA256]-----+ (base) C:\Users\ashish>Note This Error While Doing Setup on Windows
CMD> ssh-copy-id -i ./.ssh/id_rsa.pub ashish@192.168.1.100 'ssh-copy-id' is not recognized as an internal or external command, operable program or batch file.We overcome this issue by manually copying Public RSA Key into the 'authorized_keys' file of the remote machine using SFTP.
(base) C:\Users\ashish>sftp usage: sftp [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher] [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-J destination] [-l limit] [-o ssh_option] [-P port] [-R num_requests] [-S program] [-s subsystem | sftp_server] destinationNext Steps of Copying Pubic Key Onto Remote Machine And Vice-versa
Address of Ubuntu System: ashish@192.168.1.151
(base) C:\Users\ashish>sftp ashish@192.168.1.151 The authenticity of host '192.168.1.151 (192.168.1.151)' can't be established. ECDSA key fingerprint is SHA256:2hgOVHHgkrT9/6XnK/KDaFQ0DaXLUoW82eeU6oQyTvQ. Are you sure you want to continue connecting (yes/no/[fingerprint])? Warning: Permanently added '192.168.1.151' (ECDSA) to the list of known hosts. ashish@192.168.1.151's password: Connected to 192.168.1.151. sftp> ls Desktop Documents Downloads Music Pictures Public Templates Videos anaconda3 nltk_data snap sftp> byePWD: /home/ashish
sftp> put id_rsa.pub win_auth_key.txt Uploading id_rsa.pub to /home/ashish/win_auth_key.txt id_rsa.pub 100% 593 89.9KB/s 00:00 sftp>PWD: /home/ashish/.ssh
sftp> get id_rsa.pub ./ubuntu_id_rsa.pub.txt Fetching /home/ashish/.ssh/id_rsa.pub to ./ubuntu_id_rsa.pub.txt /home/ashish/.ssh/id_rsa.pub 100% 573 2.7KB/s 00:00 sftp> sftp> byeSteps on Ubuntu Machine
(base) ashish@ashishlaptop:~$ cat win_auth_key.txt ssh-rsa AAA***vZs= itli\ashish@CS3L (base) ashish@ashishlaptop:~$Paste this Public RSA Key in 'authorized_keys' File
(base) ashish@ashishlaptop:~/.ssh$ nano authorized_keys (base) ashish@ashishlaptop:~/.ssh$ cat authorized_keys ssh-rsa AAAA***rzFM= ashish@ashishdesktop ssh-rsa AAAA***GOD0= ashish@ashishlaptop ssh-rsa AAAA***3vZs= itli\ashish@CS3L (base) ashish@ashishlaptop:~/.ssh$Testing The SSH
Back to Windows 10 System
(base) C:\Users\ashish>ssh ashish@ashishlaptop The authenticity of host 'ashishlaptop (192.168.1.151)' can't be established. ECDSA key fingerprint is SHA256:2hgOVHHgkrT9/6XnK/KDaFQ0DaXLUoW82eeU6oQyTvQ. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'ashishlaptop' (ECDSA) to the list of known hosts. Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 2 updates can be applied immediately. To see these additional updates run: apt list --upgradable Last login: Wed Oct 26 13:35:44 2022 from 192.168.1.151 (base) ashish@ashishlaptop:~$ (base) ashish@ashishlaptop:~$ ls anaconda3 Desktop Documents Downloads Music nltk_data Pictures Public snap Templates Videos win_auth_key.txt (base) ashish@ashishlaptop:~$ rm win_auth_key.txt (base) ashish@ashishlaptop:~$ ls anaconda3 Desktop Documents Downloads Music nltk_data Pictures Public snap Templates Videos (base) ashish@ashishlaptop:~$ exit logout Connection to ashishlaptop closed. (base) C:\Users\ashish>ssh ashish@ashishlaptop Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 2 updates can be applied immediately. To see these additional updates run: apt list --upgradable Last login: Wed Oct 26 15:46:02 2022 from 192.168.1.100 (base) ashish@ashishlaptop:~$ client_loop: send disconnect: Connection reset (base) C:\Users\ashish>
Wednesday, October 26, 2022
SSH Setup For Accessing Ubuntu From Windows Using SFTP
Labels:
Linux,
SSH,
Technology,
Windows CMD
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment