LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-07-2019, 02:43 PM   #1
tflythe
LQ Newbie
 
Registered: Nov 2019
Posts: 1

Rep: Reputation: Disabled
Export user and password


Hello,
I want to ssh to a host and pull process info. I can do this but is there a way to export username and password so I don't have to type it every time. This is a test environment so we don't use keys.
Something like

export USERNAME=Joe
read -s PASSWORD
export PASSWORD


Thanks,
Flythe
 
Old 11-07-2019, 03:25 PM   #2
rarog
LQ Newbie
 
Registered: May 2016
Distribution: Slackware
Posts: 13

Rep: Reputation: Disabled
Hi,

You can use Expect scripts https://docs.oracle.com/cd/E35328_01...li-script.html
 
Old 11-07-2019, 03:30 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,332

Rep: Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026Reputation: 6026
Quote:
Originally Posted by tflythe View Post
Hello,
I want to ssh to a host and pull process info. I can do this but is there a way to export username and password so I don't have to type it every time. This is a test environment so we don't use keys.
Something like

export USERNAME=Joe
read -s PASSWORD
export PASSWORD
Kind of confused; if you're already using SSH, why not just type in "ssh-copy-id user@hostname", copy the key once, and be done? Why go through all the trouble to script/export things, when a single command would let you do exactly what you want?
 
Old 11-07-2019, 05:49 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
https://www.ssh.com/ssh/public-key-authentication

your distro will probably have have a better guide to setting it up

for example
https://help.ubuntu.com/community/SSH/OpenSSH/Keys
https://wiki.archlinux.org/index.php/SSH_keys
 
Old 11-07-2019, 06:27 PM   #5
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,140

Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
You can put the user in your personal .ssh/ssh_config file.

You can also wrap the ssh command in a shell script to set the user:
Code:
#!/bin/bash
ssh $USERNAME@$SERVERNAME
Since ssh is serious about security, I can't imagine putting an unencrypted password anywhere (file, environment variable, anything else) is part of its agenda.

Last edited by berndbausch; 11-07-2019 at 06:30 PM. Reason: restructuring
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash: export: `=': not a valid identifier - bash: export: `0': not a valid identifier PClOStinspace Linux - General 4 01-24-2014 02:11 PM
[SOLVED] fstab or export options needed to write to an nfs mounted ntfs export chief427 Linux - General 2 07-21-2011 08:07 AM
why should we export COMPTOP and what does !export do ? shaiva Linux - Newbie 5 11-03-2009 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration