Skip to content
Geeky Hacker

Geeky Hacker

Coding, Tech & Linux

  • Spring Boot
  • JPA
  • Kafka
  • Testing
    • Testcontainers
    • Mockito
  • Java
  • Kotlin
  • Linux
  • DevOps
    • AWS
    • CI/CD
    • Docker
    • Kubernetes
  • Database
    • MySQL
    • PostgreSQL
  • Spring Boot
  • JPA
  • Kafka
  • Testing
    • Testcontainers
    • Mockito
  • Java
  • Kotlin
  • Linux
  • DevOps
    • AWS
    • CI/CD
    • Docker
    • Kubernetes
  • Database
    • MySQL
    • PostgreSQL
Linux

Auto login using ftp command in Linux

Kasra Madadipouyaby Kasra MadadipouyaLast updated on 5 June, 2024
Default featured post

In Linux sftp allows to specify username along with the URL like this:

$ sftp username@host

However, ftp does not support such a feature. This makes it hard since one needs to remember bunch of usernames for each server. And some are so unintuitive to memorize. If a secure machine is used, not a 24/7 the Internet connected server, still there is a way to workaround the problem using switch -n.
What has to be done is to edit/create .netrc file of/to the user home directory and add an entry like this:

machine hostaddress
   login username

Then save the file and run ftp command like this:

$ ftp host

After that the ftp command picks up the username matches the host address from .netrc file and no longer requires for username, just prompts for password.

It is also possible add password to .netrc file like this:

machine hostaddress
   login username
   password password

I highly recommend against of it. It is insecure and if the system gets hack, all the credentials will be available to the crackers.

.netrc supports multiple entries, similar to following:

machine hostaddress1
   login username1

machine hostaddress2
   login username2

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • More
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print

You might also like

Default featured post

Converting .nrg file to .iso in Ubuntu terminal

Last updated on 5 June, 2024
Default featured post

Cp command with progress bar for Linux

Last updated on 5 June, 2024
Default featured post

How to install pip3 in Ubuntu 16.04

Last updated on 5 June, 2024

Popular

  • High-performance data fetching using Spring Data JPA Stream High-performance data fetching using Spring Data JPA Stream
  • Synchronize audio and video with FFmpeg Synchronize audio and video with FFmpeg
  • Test Spring Kafka consumer and producer with EmbeddedKafka Test Spring Kafka consumer and producer with EmbeddedKafka
  • How to fix grub/i386-pc/normal.mod not found How to fix grub/i386-pc/normal.mod not found
  • Configure SSH key-based authentication on Raspberry Pi Configure SSH key-based authentication on Raspberry Pi
  • Terms of Service
  • Cookie Policy
  • Privacy Policy
  • X
  • GitHub
  • Telegram
  • YouTube
  • RSS Feed
  • Cheat Sheets
  • Donate
  • Contact
© 2013-2025 Geeky Hacker Powered by WordPress and Bam.
Donate Ethereum

Yet another cryptocurrency that is super popular. You can donate us in Ethereum.

Geeky Hacker wallet number: 0x1f98767fB7c51efc35C313B0015C6aB453D4ED31

Donate BAT

BAT is a coin that is used by Brave Browser which is getting more popularity day by day.

Geeky Hacker wallet number: 0x40146D985b995E5bB5b2A7FDc618db689a811DCB

Donate Bitcoin

The unbeatable, the father and the king of kings, Bitcoin!

Geeky Hacker wallet number: 1NaGzvbXQtM9PCduXgmFeXe8D4i5C1nDyu