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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
07-21-2012, 05:34 AM
|
#1
|
Member
Registered: Feb 2011
Posts: 120
Rep:
|
ssh Connection
I am new to this.
I want to make connection to localhost via ssh. I have read some tutorials but they were for remote machine & so doesnt working on localhost.
So i want to know that how can i connect to localhost via SSH.
Thanks
|
|
|
07-21-2012, 05:37 AM
|
#2
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
If you have the SSH daemon running, you can just do "ssh localhost" or "ssh 127.0.0.1". Why do you want to do this, though?
|
|
|
07-21-2012, 05:47 AM
|
#3
|
Member
Registered: Feb 2011
Posts: 120
Original Poster
Rep:
|
I have tried this but the output i got is
Quote:
ssh: connect to host localhost port 22: Connection refused
|
|
|
|
07-21-2012, 05:48 AM
|
#4
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Did you check whether the SSH daemon is running?
|
|
|
07-21-2012, 08:25 AM
|
#5
|
Member
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179
Rep:
|
Quote:
Originally Posted by Nylex
Did you check whether the SSH daemon is running?
|
do cat /etc/hosts
find the hostname
if localhost is written.Use that ip address.
then do ssh ip_address_of_localhost
|
|
|
07-22-2012, 07:25 AM
|
#6
|
Member
Registered: Feb 2011
Posts: 120
Original Poster
Rep:
|
Ok
I have checked it
SSH was not running
But now i am getting this error on input of this command
sshd 127.0.0.1
Quote:
sshd re-exec requires execution with an absolute path
|
Now when i did this
/usr/sbin/sshd 127.0.0.1
I got this message
Quote:
Extra argument 127.0.0.1.
|
What is this ?
Last edited by Arjun; 07-22-2012 at 07:57 AM.
|
|
|
07-22-2012, 08:31 AM
|
#7
|
Member
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525
Rep:
|
Hi Arjun,
There are two totally different binary sshd (for the server aka dameon) and ssh (for client).
To ensure that the server is running, you should launch something as root
Code:
service sshd status
and look at the output
To connect to your local server from your local client, type (as any user)
Maybe will need to first search for a tutorial for SSH (just google).
|
|
|
07-22-2012, 08:39 AM
|
#8
|
Member
Registered: Feb 2011
Posts: 120
Original Poster
Rep:
|
Quote:
Originally Posted by tshikose
Hi Arjun,
There are two totally different binary sshd (for the server aka dameon) and ssh (for client).
To ensure that the server is running, you should launch something as root
Code:
service sshd status
and look at the output
To connect to your local server from your local client, type (as any user)
|
As i input
service sshd status
I got
Code:
sshd: unrecognized service
As i entered
service ssh status
I got
Code:
ssh start/running, process 2958
Seems to be running ,then how can i make it work ?
Quote:
Originally Posted by tshikose
Maybe will need to first search for a tutorial for SSH (just google).
|
I have already mentioned that i didnt got any tutorial related to ssh on localhost
|
|
|
07-22-2012, 09:34 AM
|
#9
|
Senior Member
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
|
Hi
What happens if you
Code:
ssh user@ip-of-host
|
|
|
07-22-2012, 11:29 AM
|
#10
|
LQ Newbie
Registered: Jul 2012
Location: China
Distribution: CENTOS 7
Posts: 6
Rep: 
|
Quote:
Originally Posted by Arjun
I have tried this but the output i got is
|
First do this.
Code:
vi /etc/ssh/sshd_config
Then search for "Port [number]", default is 22.BUT it's ok even if it's not 22. remember this port number.
Second
make sure you get the root previlige, then proceed
Code:
service iptables -A INPUT -p tcp --dport [the number you just remembered] -m state --state NEW -j ACCEPT
then,
Code:
service iptables save
and then
Code:
service iptables restart
it works fine for me, ssh [username]@localhost
also MAKE SURE the user of username really exists on you local machine...
for more reference, please read this article:
http://wiki.centos.org/HowTos/Network/IPTables
PS: if you are totally new to this, it really takes some time ...
Last edited by xtpeqii; 07-22-2012 at 11:34 AM.
|
|
|
07-22-2012, 06:49 PM
|
#11
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,443
|
Try (as root)
Code:
# This shows listening tcp services
netstat -tanp |grep ssh
# Looking for
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
more /etc/ssh/sshd_config
if this is on RHEL/Fedora
|
|
|
07-23-2012, 04:56 AM
|
#12
|
Member
Registered: Feb 2011
Posts: 120
Original Poster
Rep:
|
Quote:
Originally Posted by spiky0011
Hi
What happens if you
Code:
ssh user@ip-of-host
|
When i do this
ssh root@127.0.0.1
I get this
Code:
Read from socket failed: Connection reset by peer
So when i do this
sshd root@127.0.0.1
I get this
Code:
sshd re-exec requires execution with an absolute path
But when i do this
/usr/sbin/sshd root@127.0.0.1
I gets this message
Code:
Extra argument root@127.0.0.1
Quote:
Originally Posted by xtpeqii
First do this.
Code:
vi /etc/ssh/sshd_config
Then search for "Port [number]", default is 22.BUT it's ok even if it's not 22. remember this port number.
Second
make sure you get the root previlige, then proceed
Code:
service iptables -A INPUT -p tcp --dport [the number you just remembered] -m state --state NEW -j ACCEPT
|
I am getting this error message on above command
Code:
iptables: unrecognized service
I am running it as root.
|
|
|
07-23-2012, 06:07 AM
|
#13
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Quote:
Originally Posted by Arjun
So when i do this
sshd root@127.0.0.1
|
As others have mentioned above, "sshd" is the server binary so you'd never try to make an SSH connection using it. "ssh" is the client binary and that's what you use to connect.
|
|
|
07-23-2012, 11:14 AM
|
#14
|
Senior Member
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
|
Hi
What is wrong with using the true ip 192.168.xx.xx what ever it is?
Or am I missing something.
I cant ssh in using @localhost or 127.0.01 but I can using the ip add @10.42.43.1
Last edited by spiky0011; 07-23-2012 at 11:18 AM.
|
|
|
07-23-2012, 07:57 PM
|
#15
|
LQ Newbie
Registered: Jul 2012
Location: China
Distribution: CENTOS 7
Posts: 6
Rep: 
|
Quote:
Originally Posted by Arjun
I am new to this.
I want to make connection to localhost via ssh. I have read some tutorials but they were for remote machine & so doesnt working on localhost.
So i want to know that how can i connect to localhost via SSH.
Thanks
|
COULD YOU provide us the following content:
content in /etc/ssh/sshd_config
THOUGH YOU'D BETTER ASK SOMEONE WHO USE FEDORA in case of some difference between multiple distros.
Last edited by xtpeqii; 07-23-2012 at 08:00 PM.
|
|
|
All times are GMT -5. The time now is 02:52 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|